ZQuest Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2024-08-12 01:20:23
Exec Total Coverage
Lines: 8946 12531 71.4%
Functions: 98 130 75.4%
Branches: 6297 10711 58.8%

Line Branch Exec Source
1 #include "allegro/file.h"
2 #include "base/flags.h"
3 #include "base/util.h"
4 #include "base/version.h"
5 #include "base/zapp.h"
6 #include "base/qrs.h"
7 #include "base/cpool.h"
8 #include "base/autocombo.h"
9 #include "base/packfile.h"
10 #include "base/dmap.h"
11 #include "base/combo.h"
12 #include "base/msgstr.h"
13 #include <memory>
14 #include <optional>
15 #include <stdio.h>
16 #include <cstring>
17 #include <string>
18 #include <map>
19 #include <vector>
20 #include <assert.h>
21 #include <fmt/format.h>
22
23
24 #include "metadata/sigs/devsig.h.sig"
25 #include "metadata/sigs/compilersig.h.sig"
26 #include "metadata/versionsig.h"
27 #include "base/zc_alleg.h"
28 #include "base/zdefs.h"
29 #include "base/colors.h"
30 #include "tiles.h"
31 #include "base/zsys.h"
32 #include "qst.h"
33 #include "defdata.h"
34 #include "subscr.h"
35 #include "zc/replay.h"
36 #include "zc/zasm_utils.h"
37 #include "zc/zc_custom.h"
38 #include "sfx.h"
39 #include "md5.h"
40 #include "zinfo.h"
41 #include "zc/ffscript.h"
42 #include "particles.h"
43 #include "dialog/alert.h"
44 #include "base/misctypes.h"
45 #include "base/initdata.h"
46
47 extern FFScript FFCore;
48 extern ZModule zcm;
49 extern zcmodule moduledata;
50 extern uint8_t __isZQuest;
51 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
52 extern particle_list particles;
53 extern void setZScriptVersion(int32_t s_version);
54
55 static bool read_ext_zinfo = false, read_zinfo = false;
56 static bool loadquest_report = false;
57 static char const* loading_qst_name = NULL;
58 static byte loading_qst_num = 0;
59 static byte subscr_mode = ssdtMAX;
60 dword loading_tileset_flags = 0;
61
62 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0},combo_auto_listpos[MAX_COMBO_COLS]={0};
63 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
64
65 #ifdef _MSC_VER
66 #define strncasecmp _strnicmp
67 #endif
68
69 #ifndef _AL_MALLOC
70 #define _AL_MALLOC(a) _al_malloc(a)
71 #define _AL_FREE(a) _al_free(a)
72 #endif
73
74 using std::string;
75 using std::pair;
76
77 extern int32_t hero_animation_speed; //lower is faster animation
78 extern byte *colordata;
79 extern tiledata *newtilebuf;
80 extern byte *trashbuf;
81 extern itemdata *itemsbuf;
82 extern wpndata *wpnsbuf;
83 extern comboclass *combo_class_buf;
84 extern guydata *guysbuf;
85 extern ZCHEATS zcheats;
86 extern char palnames[MAXLEVELS][17];
87 extern char *byte_conversion(int32_t number, int32_t format);
88 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
89 string zScript;
90 364 std::map<int32_t, script_slot_data > ffcmap;
91 364 std::map<int32_t, script_slot_data > globalmap;
92 364 std::map<int32_t, script_slot_data > genericmap;
93 364 std::map<int32_t, script_slot_data > itemmap;
94 364 std::map<int32_t, script_slot_data > npcmap;
95 364 std::map<int32_t, script_slot_data > ewpnmap;
96 364 std::map<int32_t, script_slot_data > lwpnmap;
97 364 std::map<int32_t, script_slot_data > playermap;
98 364 std::map<int32_t, script_slot_data > dmapmap;
99 364 std::map<int32_t, script_slot_data > screenmap;
100 364 std::map<int32_t, script_slot_data > itemspritemap;
101 364 std::map<int32_t, script_slot_data > comboscriptmap;
102 364 std::map<int32_t, script_slot_data > subscreenmap;
103 void free_newtilebuf();
104 bool combosread=false;
105 bool mapsread=false;
106 bool fixffcs=false;
107 bool fixpolsvoice=false;
108
109 15036 void script_slot_data::update()
110 {
111
2/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 15032 times.
15036 switch (format)
112 {
113 case SCRIPT_FORMAT_INVALID:
114 4 output = fmt::format("{} --{}", slotname, scriptname);
115 4 break;
116 case SCRIPT_FORMAT_DISASSEMBLED:
117 output = fmt::format("{} ++{}", slotname, scriptname);
118 break;
119 case SCRIPT_FORMAT_ZASM:
120 output = fmt::format("{} =={}", slotname, scriptname);
121 break;
122 15032 case SCRIPT_FORMAT_DEFAULT:
123 default:
124 15032 output = fmt::format("{} {}", slotname, scriptname);
125 15032 }
126 15036 }
127
128 char qstdat_string[2048] = { 0 };
129
130 static zinfo* load_tmp_zi = NULL;
131
132 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
133 const byte clavio[9]={97,109,111,110,103,117,115,0};
134
135 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
136 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
137
138 const char *qst_error[] =
139 {
140 "OK","File not found","Invalid quest file",
141 "Version not supported","Obsolete version",
142 "Missing new data" , /* but let it pass in ZQuest */
143 "Internal error occurred", "Invalid password",
144 "Quest title doesn't match saved game", "Save file is for older version of quest; please start new save",
145 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
146 };
147
148 //for legacy quests -DD
149 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
150 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
151 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
152 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
153 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
154 };
155
156 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
157
158
159 char *byte_conversion(int32_t number, int32_t format)
160 {
161 static char num_str[40];
162
163 if(format==-1) //auto
164 {
165 format=1; //bytes
166
167 if(number>1024)
168 {
169 format=2; //kilobytes
170 }
171
172 if(number>1024*1024)
173 {
174 format=3; //megabytes
175 }
176
177 if(number>1024*1024*1024)
178 {
179 format=4; //gigabytes (dude, what are you doing?)
180 }
181 }
182
183 switch(format)
184 {
185 case 1: //bytes
186 sprintf(num_str,"%db",number);
187 break;
188
189 case 2: //kilobytes
190 sprintf(num_str,"%.2fk",float(number)/1024);
191 break;
192
193 case 3: //megabytes
194 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
195 break;
196
197 case 4: //gigabytes
198 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
199 break;
200
201 default:
202 abort();
203 break;
204 }
205
206 return num_str;
207 }
208
209 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
210 {
211 static char num_str1[40];
212 static char num_str2[40];
213 static char num_str[80];
214
215 if(format1==-1) //auto
216 {
217 format1=1; //bytes
218
219 if(number1>1024)
220 {
221 format1=2; //kilobytes
222 }
223
224 if(number1>1024*1024)
225 {
226 format1=3; //megabytes
227 }
228
229 if(number1>1024*1024*1024)
230 {
231 format1=4; //gigabytes (dude, what are you doing?)
232 }
233 }
234
235 if(format2==-1) //auto
236 {
237 format2=1; //bytes
238
239 if(number2>1024)
240 {
241 format2=2; //kilobytes
242 }
243
244 if(number2>1024*1024)
245 {
246 format2=3; //megabytes
247 }
248
249 if(number2>1024*1024*1024)
250 {
251 format2=4; //gigabytes (dude, what are you doing?)
252 }
253 }
254
255 switch(format1)
256 {
257 case 1: //bytes
258 sprintf(num_str1,"%db",number1);
259 break;
260
261 case 2: //kilobytes
262 sprintf(num_str1,"%.2fk",float(number1)/1024);
263 break;
264
265 case 3: //megabytes
266 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
267 break;
268
269 case 4: //gigabytes
270 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
271 break;
272
273 default:
274 abort();
275 break;
276 }
277
278 switch(format2)
279 {
280 case 1: //bytes
281 sprintf(num_str2,"%db",number2);
282 break;
283
284 case 2: //kilobytes
285 sprintf(num_str2,"%.2fk",float(number2)/1024);
286 break;
287
288 case 3: //megabytes
289 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
290 break;
291
292 case 4: //gigabytes
293 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
294 break;
295
296 default:
297 abort();
298 break;
299 }
300
301 sprintf(num_str, "%s/%s", num_str1, num_str2);
302 return num_str;
303 }
304
305 char *ordinal(int32_t num)
306 {
307 static const char *ending[4] = {"st","nd","rd","th"};
308 static char ord_str[8];
309
310 char *end;
311 int32_t t=(num%100)/10;
312 int32_t n=num%10;
313
314 if(n>=1 && n<4 && t!=1)
315 end = (char *)ending[n-1];
316 else
317 end = (char *)ending[3];
318
319 sprintf(ord_str,"%d%s",num%10000,end);
320 return ord_str;
321 }
322
323 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
324 {
325 int32_t ret;
326 *version=0;
327 *build=0;
328 byte temp_map_count=map_count;
329 byte temp_midi_flags[MIDIFLAGS_SIZE];
330 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
331
332 zquestheader tempheader;
333
334 if(!f)
335 {
336 return qe_invalid;
337 }
338
339 ret=readheader(f, &tempheader);
340
341 if(ret)
342 {
343 return ret;
344 }
345
346 map_count=temp_map_count;
347 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
348 *version=tempheader.zelda_version;
349 *build=tempheader.build;
350 return 0;
351 }
352
353
354 bool find_section(PACKFILE *f, int32_t section_id_requested)
355 {
356
357 if(!f)
358 {
359 return false;
360 }
361
362 int32_t section_id_read;
363 bool catchup=false;
364 word dummy;
365 byte tempbyte;
366 char tempbuf[65536];
367
368
369 switch(section_id_requested)
370 {
371 case ID_RULES:
372 case ID_STRINGS:
373 case ID_MISC:
374 case ID_TILES:
375 case ID_COMBOS:
376 case ID_CSETS:
377 case ID_MAPS:
378 case ID_DMAPS:
379 case ID_DOORS:
380 case ID_ITEMS:
381 case ID_WEAPONS:
382 case ID_COLORS:
383 case ID_ICONS:
384 case ID_INITDATA:
385 case ID_GUYS:
386 case ID_MIDIS:
387 case ID_CHEATS:
388 break;
389
390 default:
391 al_trace("Bad section requested!\n");
392 return false;
393 break;
394 }
395
396 dword section_size;
397
398 //section id
399 if(!p_mgetl(&section_id_read,f))
400 {
401 return false;
402 }
403
404 while(!pack_feof(f))
405 {
406 switch(section_id_read)
407 {
408 case ID_RULES:
409 case ID_STRINGS:
410 case ID_MISC:
411 case ID_TILES:
412 case ID_COMBOS:
413 case ID_CSETS:
414 case ID_MAPS:
415 case ID_DMAPS:
416 case ID_DOORS:
417 case ID_ITEMS:
418 case ID_WEAPONS:
419 case ID_COLORS:
420 case ID_ICONS:
421 case ID_INITDATA:
422 case ID_GUYS:
423 case ID_MIDIS:
424 case ID_CHEATS:
425 catchup=false;
426 break;
427
428 default:
429 break;
430 }
431
432
433 while(catchup)
434 {
435 //section id
436 section_id_read=(section_id_read<<8);
437
438 if(!p_getc(&tempbyte,f))
439 {
440 return false;
441 }
442
443 section_id_read+=tempbyte;
444 }
445
446 if(section_id_read==section_id_requested)
447 {
448 return true;
449 }
450 else
451 {
452 //section version info
453 if(!p_igetw(&dummy,f))
454 {
455 return false;
456 }
457
458 if(!p_igetw(&dummy,f))
459 {
460 return false;
461 }
462
463 //section size
464 if(!p_igetl(&section_size,f))
465 {
466 return false;
467 }
468
469 //pack_fseek(f, section_size);
470 while(section_size>65535)
471 {
472 pfread(tempbuf,65535,f);
473 tempbuf[65535]=0;
474 section_size-=65535;
475 }
476
477 if(section_size>0)
478 {
479 pfread(tempbuf,section_size,f);
480 tempbuf[section_size]=0;
481 }
482 }
483
484 //section id
485 if(!p_mgetl(&section_id_read,f))
486 {
487 return false;
488 }
489 }
490
491 return false;
492 }
493
494
495
496
497
498 bool valid_zqt(PACKFILE *f)
499 {
500
501 //word tiles_used;
502 //word combos_used;
503 //open the file
504 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
505 if(!f)
506 return false;
507
508 //for now, everything else is valid
509 return true;
510
511 /*int16_t version;
512 byte build;
513
514 //read the version and make sure it worked
515 if(!p_igetw(&version,f))
516 {
517 goto error;
518 }
519
520 //read the build and make sure it worked
521 if(!p_getc(&build,f))
522 goto error;
523
524 //read the tile info and make sure it worked
525 if(!p_igetw(&tiles_used,f))
526 {
527 goto error;
528 }
529
530 for (int32_t i=0; i<tiles_used; i++)
531 {
532 if(!pfread(trashbuf,tilesize(tf4Bit),f))
533 {
534 goto error;
535 }
536 }
537
538 //read the combo info and make sure it worked
539 if(!p_igetw(&combos_used,f))
540 {
541 goto error;
542 }
543 for (int32_t i=0; i<combos_used; i++)
544 {
545 if(!pfread(trashbuf,sizeof(newcombo),f))
546 {
547 goto error;
548 }
549 }
550
551 //read the palette info and make sure it worked
552 for (int32_t i=0; i<48; i++)
553 {
554 if(!pfread(trashbuf,newpdTOTAL,f))
555 {
556 goto error;
557 }
558 }
559 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f))
560 {
561 goto error;
562 }
563 for (int32_t i=0; i<MAXLEVELS; i++)
564 {
565 if(!pfread(trashbuf,PALNAMESIZE,f))
566 {
567 goto error;
568 }
569 }
570
571 //read the sprite info and make sure it worked
572 for (int32_t i=0; i<MAXITEMS; i++)
573 {
574 if(!pfread(trashbuf,sizeof(itemdata),f))
575 {
576 goto error;
577 }
578 }
579
580 for (int32_t i=0; i<MAXWPNS; i++)
581 {
582 if(!pfread(trashbuf,sizeof(wpndata),f))
583 {
584 goto error;
585 }
586 }
587
588 //read the triforce pieces info and make sure it worked
589 for (int32_t i=0; i<8; ++i)
590 {
591 if(!p_getc(&trashbuf,f))
592 {
593 goto error;
594 }
595 }
596
597
598
599 //read the game icons info and make sure it worked
600 for (int32_t i=0; i<4; ++i)
601 {
602 if(!p_igetw(&trashbuf,f))
603 {
604 goto error;
605 }
606 }
607
608 //read the misc colors info and map styles info and make sure it worked
609 if(!pfread(trashbuf,sizeof(zcolors),f))
610 {
611 goto error;
612 }
613
614 //read the template screens and make sure it worked
615 byte num_maps;
616 if(!p_getc(&num_maps,f))
617 {
618 goto error;
619 }
620 for (int32_t i=0; i<TEMPLATES; i++)
621 {
622 if(!pfread(trashbuf,sizeof(mapscr),f))
623 {
624 goto error;
625 }
626 }
627 if (num_maps>1) //dungeon templates
628 {
629 for (int32_t i=0; i<TEMPLATES; i++)
630 {
631 if(!pfread(trashbuf,sizeof(mapscr),f))
632 {
633 goto error;
634 }
635 }
636 }
637
638 //yay! it worked! close the file and say everything was ok.
639 pack_fclose(f);
640 return true;
641
642 error:
643 pack_fclose(f);
644 return false;*/
645 }
646
647 bool valid_zqt(const char *filename)
648 {
649 PACKFILE *f=NULL;
650 bool isvalid;
651 int32_t error;
652 f=open_quest_file(&error, filename, false);
653
654 if(!f)
655 {
656 // setPackfilePassword(NULL);
657 return false;
658 }
659
660 isvalid=valid_zqt(f);
661
662 clear_quest_tmpfile();
663 pack_fclose(f);
664
665 // setPackfilePassword(NULL);
666 return isvalid;
667 }
668
669 /*
670 .qst file history
671
672 .qst files have always been compressed using allegro's packfiles.
673
674 At some point, an encoding layer was added. The two layers look like this:
675
676 1) The top layer is from us. See decode_file_007.
677 [0-24] Preamble "Zelda Classic Quest File"
678 [25-28] Initial decoding seed value.
679 [29-X] Allegro-compressed payload (AKA "packed" file), but XOR'd based on seed value
680 [last 4] Checksum
681
682 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
683 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
684 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
685 The oldest quests skip the password part.
686
687 Simply, the job of this function is to peel away the top layer.
688
689 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
690 in opening and saving files. There is no version field, so they decryption key is
691 found via trial-by-error (very slow!)
692
693 There are other file types of interest:
694 - .zqt: quest template files, skips top-layer encryption pass
695 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
696 - .qu?: same as above. automated backup files
697 - .qb?: same as above. automated backup files
698 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
699
700 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
701 files are now "slh!.AG ZC Enhanced Quest File".
702 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
703 */
704 693 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
705 {
706
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 1 times.
693 if (show_progress)
707 {
708 1 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
709 1 }
710
711 693 auto unencrypted_result = try_open_maybe_legacy_encoded_file(filename, ENC_STR, nullptr, QH_NEWIDSTR, QH_IDSTR);
712
2/2
✓ Branch 0 taken 533 times.
✓ Branch 1 taken 160 times.
693 if (unencrypted_result.decoded_pf)
713 533 return unencrypted_result.decoded_pf;
714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
160 if (unencrypted_result.not_found)
715 {
716 *open_error = qe_notfound;
717 return nullptr;
718 }
719
720 // Everything below here is legacy code - recently saved quest files will have
721 // returned by now.
722 // The only replay qst file that is still using this legacy encoding is `link_to_the_zelda.qst`.
723
724 // Note: although this is primarily for loading .qst files, it can also handle all of the
725 // file types mentioned in the comment above. No need to be told if the file being loaded
726 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
727 160 bool top_layer_compressed = unencrypted_result.top_layer_compressed;
728 160 bool compressed = unencrypted_result.compressed;
729 160 bool encrypted = unencrypted_result.encrypted;
730
731 char tmpfilename[L_tmpnam];
732 160 temp_name(tmpfilename);
733 char percent_done[30];
734 160 int32_t current_method=0;
735
736 PACKFILE *f;
737 160 const char *passwd= encrypted ? datapwd : "";
738
739 // oldquest flag is set when an unencrypted qst file is suspected.
740 160 bool oldquest = false;
741 int32_t ret;
742
743
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 if(strcmp(filename, "default.qst")!=0)
744 {
745 160 box_out(filename);
746 160 }
747 else
748 {
749 box_out("new quest"); // Or whatever
750 }
751 160 box_out("...");
752 160 box_eol();
753 160 box_eol();
754
755
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 if(encrypted)
756 {
757 160 box_out("Decrypting...");
758 160 box_save_x();
759 160 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
760
761
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 63 times.
160 if(ret)
762 {
763
1/3
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
63 switch(ret)
764 {
765 case 1:
766 box_out("error.");
767 box_eol();
768 box_end(true);
769 *open_error=qe_notfound;
770 return NULL;
771
772 case 2:
773 box_out("error.");
774 box_eol();
775 box_end(true);
776 *open_error=qe_internal;
777 return NULL;
778 // be sure not to delete tmpfilename now...
779 }
780
781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
782 {
783 63 current_method++;
784 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
785 63 box_out(percent_done);
786 63 box_load_x();
787 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
788 63 }
789
790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
791 {
792 63 current_method++;
793 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
794 63 box_out(percent_done);
795 63 box_load_x();
796 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
797 63 }
798
799
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 18 times.
63 if(ret==5) //old encryption?
800 {
801 18 current_method++;
802 18 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
803 18 box_out(percent_done);
804 18 box_load_x();
805 18 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
806 18 }
807
808
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 12 times.
63 if(ret==5) //old encryption?
809 {
810 12 current_method++;
811 12 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
812 12 box_out(percent_done);
813 12 box_load_x();
814 12 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
815 12 }
816
817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret)
818 {
819 oldquest = true;
820 passwd="";
821 }
822 63 }
823
824 160 box_out("okay.");
825 160 box_eol();
826 160 }
827 else
828 {
829 oldquest = true;
830 }
831
832 160 box_out("Opening...");
833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
160 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
834
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 if(!f)
835 {
836 if((compressed==1)&&(errno==EDOM))
837 {
838 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
839 }
840
841 if(!f)
842 {
843 if(!oldquest)
844 {
845 delete_file(tmpfilename);
846 }
847 box_out("error.");
848 box_eol();
849 box_end(true);
850 *open_error=qe_invalid;
851 return NULL;
852 }
853 }
854
855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
160 if(!oldquest)
856 {
857 160 delete_file(tmpfilename);
858 160 }
859
860 160 box_out("okay.");
861 160 box_eol();
862
863 160 return f;
864 693 }
865
866 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
867 {
868 char *filename;
869 PACKFILE *f=NULL;
870 int32_t open_error=0;
871
872 strcpy(qstdat_string, "modules/classic/default.qst");
873 if(Header->templatepath[0]==0)
874 {
875 filename=(char *)malloc(2048);
876 strcpy(filename, qstdat_string);
877 }
878 else
879 {
880 // TODO: should be safe to remove this, no one seems to use custom quest templates.
881 filename=Header->templatepath;
882 }
883
884 f=open_quest_file(&open_error, filename, false);
885
886 if(Header->templatepath[0]==0)
887 {
888 free(filename);
889 }
890
891 if(!f)
892 {
893 return NULL;
894 }
895
896 if(validate)
897 {
898 if(!valid_zqt(f))
899 {
900 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
901 pack_fclose(f);
902 clear_quest_tmpfile();
903 return NULL;
904 }
905 }
906
907 return f;
908 }
909
910 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
911 {
912 // We absolutely do not support loading from a template file to initialize data outside the editor.
913 // TODO: move this code into zq/
914 if (get_app_id() != App::zquest) return false;
915
916 combosread=false;
917 mapsread=false;
918 fixffcs=false;
919
920 switch(section_id)
921 {
922 case ID_RULES:
923 case ID_STRINGS:
924 case ID_MISC:
925 case ID_TILES:
926 case ID_COMBOS:
927 case ID_CSETS:
928 case ID_MAPS:
929 case ID_DMAPS:
930 case ID_DOORS:
931 case ID_ITEMS:
932 case ID_WEAPONS:
933 case ID_COLORS:
934 case ID_ICONS:
935 case ID_INITDATA:
936 case ID_GUYS:
937 case ID_MIDIS:
938 case ID_CHEATS:
939 case ID_ITEMDROPSETS:
940 case ID_FAVORITES:
941 break;
942
943 default:
944 return false;
945 break;
946 }
947
948 int32_t ret;
949 word version, build;
950 PACKFILE *f=NULL;
951
952 char deletefilename[1024];
953 deletefilename[0]=0;
954
955 //why is this here?
956 /*
957 if(colordata==NULL)
958 return false;
959 */
960
961 //setPackfilePassword(datapwd);
962 f=open_quest_template(Header, deletefilename, validate);
963
964 if(!f) //no file, nothing to delete
965 {
966 // setPackfilePassword(NULL);
967 return false;
968 }
969
970 ret=get_version_and_build(f, &version, &build);
971
972 if(ret||(version==0))
973 {
974 pack_fclose(f);
975 clear_quest_tmpfile();
976
977 if(deletefilename[0])
978 {
979 delete_file(deletefilename);
980 }
981
982 // setPackfilePassword(NULL);
983 return false;
984 }
985
986 if(!find_section(f, section_id))
987 {
988 al_trace("Can't find section!\n");
989 pack_fclose(f);
990 clear_quest_tmpfile();
991
992 if(deletefilename[0])
993 {
994 delete_file(deletefilename);
995 }
996
997 //setPackfilePassword(NULL);
998 return false;
999 }
1000
1001 switch(section_id)
1002 {
1003 case ID_RULES:
1004 //rules
1005 ret=readrules(f, Header);
1006 break;
1007
1008 case ID_STRINGS:
1009 //strings
1010 ret=readstrings(f, Header);
1011 break;
1012
1013 case ID_MISC:
1014 //misc data
1015 ret=readmisc(f, Header, Misc);
1016 break;
1017
1018 case ID_TILES:
1019 //tiles
1020 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true);
1021 break;
1022
1023 case ID_COMBOS:
1024 //combos
1025 clear_combos();
1026 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS);
1027 combosread=true;
1028 break;
1029
1030 case ID_COMBOALIASES:
1031 //combos
1032 ret=readcomboaliases(f, Header, version, build);
1033 break;
1034
1035 case ID_CSETS:
1036 //color data
1037 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL);
1038 break;
1039
1040 case ID_MAPS:
1041 //maps
1042 ret=readmaps(f, Header);
1043 mapsread=true;
1044 break;
1045
1046 case ID_DMAPS:
1047 //dmaps
1048 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS);
1049 break;
1050
1051 case ID_DOORS:
1052 //door combo sets
1053 ret=readdoorcombosets(f, Header);
1054 break;
1055
1056 case ID_ITEMS:
1057 //items
1058 ret=readitems(f, version, build);
1059 break;
1060
1061 case ID_WEAPONS:
1062 //weapons
1063 ret=readweapons(f, Header);
1064 break;
1065
1066 case ID_COLORS:
1067 //misc. colors
1068 ret=readmisccolors(f, Header, Misc);
1069 break;
1070
1071 case ID_ICONS:
1072 //game icons
1073 ret=readgameicons(f, Header, Misc);
1074 break;
1075
1076 case ID_INITDATA:
1077 //initialization data
1078 ret=readinitdata(f, Header);
1079 break;
1080
1081 case ID_GUYS:
1082 //guys
1083 ret=readguys(f, Header);
1084 break;
1085
1086 case ID_MIDIS:
1087 //midis
1088 ret=readtunes(f, Header, tunes);
1089 break;
1090
1091 case ID_CHEATS:
1092 //cheat codes
1093 ret=readcheatcodes(f, Header);
1094 break;
1095
1096 case ID_ITEMDROPSETS:
1097 //item drop sets
1098 // Why is this one commented out?
1099 //ret=readitemdropsets(f, (int32_t)version, (word)build);
1100 break;
1101
1102 case ID_FAVORITES:
1103 // favorite combos and aliases
1104 ret=readfavorites(f, version, build);
1105 break;
1106
1107 default:
1108 ret=-1;
1109 break;
1110 }
1111
1112 pack_fclose(f);
1113 clear_quest_tmpfile();
1114
1115 if(deletefilename[0])
1116 {
1117 delete_file(deletefilename);
1118 }
1119
1120 //setPackfilePassword(NULL);
1121 if(!ret)
1122 {
1123 return true;
1124 }
1125
1126 return false;
1127 }
1128
1129 bool init_tiles(bool validate, zquestheader *Header)
1130 {
1131 return init_section(Header, ID_TILES, NULL, NULL, validate);
1132 }
1133
1134 bool init_combos(bool validate, zquestheader *Header)
1135 {
1136 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1137 }
1138
1139 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1140 {
1141 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1142 }
1143
1144 693 void init_spritelists()
1145 {
1146
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 421 times.
693 if(FFCore.quest_format[vZelda] < 0x255)
1147 {
1148 272 guys.setMax(255);
1149 272 items.setMax(255);
1150 272 Ewpns.setMax(255);
1151 272 Lwpns.setMax(255);
1152 272 chainlinks.setMax(255);
1153 272 decorations.setMax(255);
1154 272 particles.setMax(255);
1155 272 }
1156 else
1157 {
1158 421 guys.setMax(255);
1159 421 items.setMax(255);
1160 421 Ewpns.setMax(255);
1161 421 Lwpns.setMax(255);
1162 421 chainlinks.setMax(255);
1163 421 decorations.setMax(255);
1164 421 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1165 }
1166 693 }
1167
1168 265 bool reset_items(bool validate, zquestheader *Header)
1169 {
1170 265 bool ret = true;
1171
1/2
✓ Branch 0 taken 265 times.
✗ Branch 1 not taken.
265 if (get_app_id() == App::zquest)
1172 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1173
1174
2/2
✓ Branch 0 taken 265 times.
✓ Branch 1 taken 67840 times.
68105 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1175
1176 265 return ret;
1177 }
1178
1179 bool reset_guys()
1180 {
1181 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1182 init_guys(V_GUYS);
1183 return true;
1184 }
1185
1186 bool reset_wpns(bool validate, zquestheader *Header)
1187 {
1188 bool ret = true;
1189 if (get_app_id() == App::zquest)
1190 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1191
1192 for(int32_t i=0; i<MAXWPNS; i++)
1193 reset_weaponname(i);
1194
1195 return ret;
1196 }
1197
1198 bool reset_mapstyles(bool validate, miscQdata *Misc)
1199 {
1200 Misc->colors.blueframe_tile = 20044;
1201 Misc->colors.blueframe_cset = 0;
1202 Misc->colors.triforce_tile = 23461;
1203 Misc->colors.triforce_cset = 1;
1204 Misc->colors.triframe_tile = 18752;
1205 Misc->colors.triframe_cset = 1;
1206 Misc->colors.overworld_map_tile = 16990;
1207 Misc->colors.overworld_map_cset = 2;
1208 Misc->colors.HCpieces_tile = 21160;
1209 Misc->colors.HCpieces_cset = 8;
1210 Misc->colors.dungeon_map_tile = 19651;
1211 Misc->colors.dungeon_map_cset = 8;
1212 return true;
1213 }
1214
1215 313 int32_t get_qst_buffers()
1216 {
1217 313 TheMaps.resize(MAPSCRS);
1218 313 map_autolayers.resize(6);
1219
1220
2/2
✓ Branch 0 taken 42568 times.
✓ Branch 1 taken 313 times.
42881 for(int32_t i(0); i<MAPSCRS; i++)
1221 42568 TheMaps[i].zero_memory();
1222
1223 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1224 313 Z_message("OK\n");
1225
1226 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1227 // (Shoelace's "Hero of Dreams" uses 1415.)
1228 // So let's be a bit generous and allow 4096 initially.
1229 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1230 // I tested it and it worked without flaw on 6/6/11. - L.
1231 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1232 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1233 // See https://discord.com/channels/876899628556091432/992984989073416242
1234 313 msg_strings_size = 8192;
1235
1236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 313 times.
313 MsgStrings = new MsgStr[msg_strings_size];
1237
1238 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1239
2/2
✓ Branch 0 taken 2564096 times.
✓ Branch 1 taken 313 times.
2564409 for(auto q = 0; q < msg_strings_size; ++q)
1240 {
1241 2564096 MsgStrings[q].clear();
1242 2564096 }
1243
1244
1245
1/2
✓ Branch 0 taken 313 times.
✗ Branch 1 not taken.
313 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1246 return 0;
1247
1248
1249
1250
1/2
✓ Branch 0 taken 313 times.
✗ Branch 1 not taken.
313 if((DMaps=new dmap[MAXDMAPS])==NULL)
1251 return 0;
1252
1253
1254
1255 313 combobuf.clear();
1256 313 combobuf.resize(MAXCOMBOS);
1257
1258
1259
1/2
✓ Branch 0 taken 313 times.
✗ Branch 1 not taken.
313 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1260 return 0;
1261
1262 313 free_newtilebuf();
1263
1/2
✓ Branch 0 taken 313 times.
✗ Branch 1 not taken.
313 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1264 return 0;
1265
1266 313 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1267 //Z_message("Performed memset on tiles\n");
1268 313 clear_tiles(newtilebuf);
1269 //Z_message("Performed clear_tiles()\n");
1270
1271
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 10 times.
313 if(is_editor())
1272 {
1273
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1274 return 0;
1275
1276 10 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1277 10 clear_tiles(grabtilebuf);
1278 10 }
1279
1280
1/2
✓ Branch 0 taken 313 times.
✗ Branch 1 not taken.
313 if((trashbuf=(byte*)malloc(100000))==NULL)
1281 return 0;
1282
1283 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1284 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1285 // fixed by ensuring there's actually itemdata there.
1286 // If you change this, be sure to update del_qst_buffers, too.
1287
1288
1/2
✓ Branch 0 taken 313 times.
✗ Branch 1 not taken.
313 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1289 return 0;
1290
1291 313 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1292 313 itemsbuf++;
1293
1294
1/2
✓ Branch 0 taken 313 times.
✗ Branch 1 not taken.
313 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1295 return 0;
1296
1297 313 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1298
1299
1/2
✓ Branch 0 taken 313 times.
✗ Branch 1 not taken.
313 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1300 return 0;
1301
1302 313 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1303
1304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 313 times.
313 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1305 return 0;
1306
1307 313 return 1;
1308 313 }
1309
1310
1311 313 void free_newtilebuf()
1312 {
1313
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 312 times.
313 if(newtilebuf)
1314 {
1315
2/2
✓ Branch 0 taken 214500 times.
✓ Branch 1 taken 1 times.
214501 for(int32_t i=0; i<NEWMAXTILES; i++)
1316
1/2
✓ Branch 0 taken 214500 times.
✗ Branch 1 not taken.
214500 if(newtilebuf[i].data)
1317 free(newtilebuf[i].data);
1318
1319 1 free(newtilebuf);
1320 1 newtilebuf = 0;
1321 1 }
1322 313 }
1323
1324 void free_grabtilebuf()
1325 {
1326 if(is_editor())
1327 {
1328 if(grabtilebuf)
1329 {
1330 for(int32_t i=0; i<NEWMAXTILES; i++)
1331 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1332
1333 free(grabtilebuf);
1334 grabtilebuf = 0;
1335 }
1336 }
1337 }
1338
1339 void del_qst_buffers()
1340 {
1341 if(MsgStrings) delete[] MsgStrings;
1342
1343 if(DoorComboSets) free(DoorComboSets);
1344
1345 if (DMaps) delete[] DMaps;
1346
1347 combobuf.clear();
1348
1349 if(colordata) free(colordata);
1350
1351 free_newtilebuf();
1352 free_grabtilebuf();
1353
1354 if(trashbuf) free(trashbuf);
1355
1356 // See get_qst_buffers
1357 if(itemsbuf)
1358 {
1359 itemsbuf--;
1360 free(itemsbuf);
1361 }
1362
1363 if(wpnsbuf) free(wpnsbuf);
1364
1365 if(guysbuf) free(guysbuf);
1366
1367 if(combo_class_buf) free(combo_class_buf);
1368 }
1369
1370 18 bool init_palnames()
1371 {
1372 // if(palnames==NULL)
1373 // return false;
1374
1375
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 18 times.
9234 for(int32_t x=0; x<MAXLEVELS; x++)
1376 {
1377
4/4
✓ Branch 0 taken 9162 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 18 times.
9216 switch(x)
1378 {
1379 case 0:
1380 18 sprintf(palnames[x],"Overworld");
1381 18 break;
1382
1383 case 10:
1384 18 sprintf(palnames[x],"Caves");
1385 18 break;
1386
1387 case 11:
1388 18 sprintf(palnames[x],"Passageways");
1389 18 break;
1390
1391 default:
1392 9162 sprintf(palnames[x],"%c",0);
1393 9162 break;
1394 }
1395 9216 }
1396
1397 18 return true;
1398 }
1399
1400 97799 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size)
1401 {
1402 void *p;
1403
1404
1/2
✓ Branch 0 taken 97799 times.
✗ Branch 1 not taken.
97799 p = _AL_MALLOC(MAX(size, alloc_size));
1405
1406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97799 times.
97799 if(!p)
1407 {
1408 return NULL;
1409 }
1410
1411
1/2
✓ Branch 0 taken 97799 times.
✗ Branch 1 not taken.
97799 if(!pfread(p,size,f))
1412 {
1413 _AL_FREE(p);
1414 return NULL;
1415 }
1416
1417
1/2
✓ Branch 0 taken 97799 times.
✗ Branch 1 not taken.
97799 if(pack_ferror(f))
1418 {
1419 _AL_FREE(p);
1420 return NULL;
1421 }
1422
1423 97799 return p;
1424 97799 }
1425
1426 // Only use for reading parts of older quests (Header->zelda_version <= 0x192)
1427 static const byte* legacy_skip_flags;
1428
1429 /* read_midi:
1430 * Reads MIDI data from a datafile (this is not the same thing as the
1431 * standard midi file format).
1432 */
1433
1434 10241 static MIDI *read_midi(PACKFILE *f)
1435 {
1436 MIDI *m;
1437 int32_t c;
1438 10241 int16_t divisions=0;
1439 10241 int32_t len=0;
1440
1441 10241 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1442
1443
1/2
✓ Branch 0 taken 10241 times.
✗ Branch 1 not taken.
10241 if(!m)
1444 {
1445 return NULL;
1446 }
1447
1448
2/2
✓ Branch 0 taken 327712 times.
✓ Branch 1 taken 10241 times.
337953 for(c=0; c<MIDI_TRACKS; c++)
1449 {
1450 327712 m->track[c].len = 0;
1451 327712 m->track[c].data = NULL;
1452 327712 }
1453
1454 10241 p_mgetw(&divisions,f);
1455 10241 m->divisions=divisions;
1456
1457
2/2
✓ Branch 0 taken 327712 times.
✓ Branch 1 taken 10241 times.
337953 for(c=0; c<MIDI_TRACKS; c++)
1458 {
1459 327712 p_mgetl(&len,f);
1460 327712 m->track[c].len=len;
1461
1462
2/2
✓ Branch 0 taken 229913 times.
✓ Branch 1 taken 97799 times.
327712 if(m->track[c].len > 0)
1463 {
1464 97799 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0);
1465
1466
1/2
✓ Branch 0 taken 97799 times.
✗ Branch 1 not taken.
97799 if(!m->track[c].data)
1467 {
1468 destroy_midi(m);
1469 return NULL;
1470 }
1471 97799 }
1472 327712 }
1473
1474 LOCK_DATA(m, sizeof(MIDI));
1475
1476
2/2
✓ Branch 0 taken 327712 times.
✓ Branch 1 taken 10241 times.
337953 for(c=0; c<MIDI_TRACKS; c++)
1477 {
1478
2/2
✓ Branch 0 taken 97799 times.
✓ Branch 1 taken 229913 times.
327712 if(m->track[c].data)
1479 {
1480 LOCK_DATA(m->track[c].data, m->track[c].len);
1481 97799 }
1482 327712 }
1483
1484 10241 return m;
1485 10241 }
1486
1487 void clear_combo(int32_t i)
1488 {
1489 combobuf[i].clear();
1490 }
1491
1492 void clear_combos()
1493 {
1494 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1495 clear_combo(tmpcounter);
1496 }
1497
1498 void pack_combos()
1499 {
1500 int32_t di = 0;
1501
1502 for(int32_t si=0; si<1024; si+=2)
1503 combobuf[di++] = combobuf[si];
1504
1505 for(; di<1024; di++)
1506 clear_combo(di);
1507 }
1508
1509 692 void reset_tunes(zctune *tune)
1510 {
1511
2/2
✓ Branch 0 taken 174384 times.
✓ Branch 1 taken 692 times.
175076 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1512 {
1513 174384 tune[i].reset();
1514 174384 }
1515 692 }
1516
1517
1518 /*void reset_midi(zcmidi_ *m)
1519 {
1520 m->title[0]=0;
1521 m->loop=1;
1522 m->volume=144;
1523 m->start=0;
1524 m->loop_start=-1;
1525 m->loop_end=-1;
1526 if(m->midi)
1527 {
1528 destroy_midi(m->midi);
1529 }
1530 m->midi=NULL;
1531 }
1532
1533
1534 void reset_midis(zcmidi_ *m)
1535 {
1536 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1537 {
1538 reset_midi(m+i);
1539 }
1540 }
1541 */
1542
1543 void reset_scr(int32_t scr)
1544 {
1545 /*
1546 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1547 for(unsigned i=0; i<sizeof(mapscr); i++)
1548 *(di++) = 0;
1549 TheMaps[scr].valid=mVERSION;
1550 */
1551
1552 TheMaps[scr].zero_memory();
1553 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1554
1555 for(int32_t i=0; i<6; i++)
1556 {
1557 //these will be uncommented later
1558 //TheMaps[scr].layerxsize[i]=16;
1559 //TheMaps[scr].layerysize[i]=11;
1560 TheMaps[scr].layeropacity[i]=255;
1561 }
1562
1563 TheMaps[scr].valid=mVERSION;
1564
1565 }
1566
1567 /* For reference:
1568
1569 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1570 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1571 */
1572
1573 28922 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1574 {
1575
2/2
✓ Branch 0 taken 63938 times.
✓ Branch 1 taken 4377 times.
68315 for(int32_t i=0; i<9; i++)
1576 {
1577
2/2
✓ Branch 0 taken 262433 times.
✓ Branch 1 taken 39699 times.
302132 for(int32_t j=0; j<6; j++)
1578 {
1579
2/2
✓ Branch 0 taken 79398 times.
✓ Branch 1 taken 183035 times.
262433 if(j<4)
1580 {
1581
2/2
✓ Branch 0 taken 158796 times.
✓ Branch 1 taken 24239 times.
183035 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1582 {
1583 24239 return false;
1584 }
1585
1586
1/2
✓ Branch 0 taken 158796 times.
✗ Branch 1 not taken.
158796 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1587 {
1588 return false;
1589 }
1590
1591
1/2
✓ Branch 0 taken 158796 times.
✗ Branch 1 not taken.
158796 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1592 {
1593 return false;
1594 }
1595
1596
1/2
✓ Branch 0 taken 158796 times.
✗ Branch 1 not taken.
158796 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1597 {
1598 return false;
1599 }
1600 158796 }
1601
1602
1/2
✓ Branch 0 taken 238194 times.
✗ Branch 1 not taken.
238194 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1603 {
1604 return false;
1605 }
1606
1607
1/2
✓ Branch 0 taken 238194 times.
✗ Branch 1 not taken.
238194 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1608 {
1609 return false;
1610 }
1611
1612
1/2
✓ Branch 0 taken 238194 times.
✗ Branch 1 not taken.
238194 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1613 {
1614 return false;
1615 }
1616
1617
1/2
✓ Branch 0 taken 238194 times.
✗ Branch 1 not taken.
238194 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1618 {
1619 return false;
1620 }
1621 238194 }
1622
1623
2/2
✓ Branch 0 taken 30639 times.
✓ Branch 1 taken 9060 times.
39699 if(i<2)
1624 {
1625
1/2
✓ Branch 0 taken 9060 times.
✗ Branch 1 not taken.
9060 if(a.flags[i]!=b.flags[i])
1626 {
1627 return false;
1628 }
1629
1630
2/2
✓ Branch 0 taken 9036 times.
✓ Branch 1 taken 24 times.
9060 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1631 {
1632 24 return false;
1633 }
1634
1635
1/2
✓ Branch 0 taken 9036 times.
✗ Branch 1 not taken.
9036 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1636 {
1637 return false;
1638 }
1639
1640
1/2
✓ Branch 0 taken 9036 times.
✗ Branch 1 not taken.
9036 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1641 {
1642 return false;
1643 }
1644
1645
1/2
✓ Branch 0 taken 9036 times.
✗ Branch 1 not taken.
9036 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1646 {
1647 return false;
1648 }
1649 9036 }
1650
1651
2/2
✓ Branch 0 taken 26262 times.
✓ Branch 1 taken 13413 times.
39675 if(i<3)
1652 {
1653
1/2
✓ Branch 0 taken 13413 times.
✗ Branch 1 not taken.
13413 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1654 {
1655 return false;
1656 }
1657
1658
1/2
✓ Branch 0 taken 13413 times.
✗ Branch 1 not taken.
13413 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1659 {
1660 return false;
1661 }
1662
1663
1/2
✓ Branch 0 taken 13413 times.
✗ Branch 1 not taken.
13413 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1664 {
1665 return false;
1666 }
1667
1668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13413 times.
13413 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1669 {
1670 return false;
1671 }
1672 13413 }
1673
1674
2/2
✓ Branch 0 taken 39393 times.
✓ Branch 1 taken 282 times.
39675 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1675 {
1676 282 return false;
1677 }
1678
1679
1/2
✓ Branch 0 taken 39393 times.
✗ Branch 1 not taken.
39393 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1680 {
1681 return false;
1682 }
1683 39393 }
1684
1685 4377 return true;
1686 28922 }
1687
1688 int32_t doortranslations_u[9][4]=
1689 {
1690 {37,38,53,54},
1691 {37,38,39,40},
1692 {37,38,55,56},
1693 {37,38,39,40},
1694 {37,38,53,54},
1695 {37,38,53,54},
1696 {37,38,53,54},
1697 {7,8,23,24},
1698 {7,8,41,42}
1699 };
1700
1701 int32_t doortranslations_d[9][4]=
1702 {
1703 {117,118,133,134},
1704 {135,136,133,134},
1705 {119,120,133,134},
1706 {135,136,133,134},
1707 {117,118,133,134},
1708 {117,118,133,134},
1709 {117,118,133,134},
1710 {151,152,167,168},
1711 {137,138,167,168},
1712 };
1713
1714 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1715 int32_t doortranslations_l[9][6]=
1716 {
1717 {66,67,82,83,98,99},
1718 {66,68,82,84,98,100},
1719 {66,69,82,85,98,101},
1720 {66,68,82,84,98,100},
1721 {66,67,82,83,98,99},
1722 {66,67,82,83,98,99},
1723 {66,67,82,83,98,99},
1724 {64,65,80,81,96,97},
1725 {64,65,80,114,96,97},
1726 };
1727
1728 int32_t doortranslations_r[9][6]=
1729 {
1730
1731 {76,77,92,93,108,109},
1732 {75,77,91,93,107,109},
1733 {74,77,90,93,106,109},
1734 {75,77,91,93,107,109},
1735 {76,77,92,93,108,109},
1736 {76,77,92,93,108,109},
1737 {76,77,92,93,108,109},
1738 {78,79,94,95,110,111},
1739 {78,79,125,95,110,111},
1740 };
1741
1742 858450 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1743 {
1744 858450 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1745 }
1746
1747 840750 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1748 {
1749 //these are here to bypass compiler warnings about unused arguments
1750 840750 map=map;
1751 840750 scr=scr;
1752 840750 pos=pos;
1753
1754 //what does this function do?
1755 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1756 840750 return 2;
1757 }
1758
1759 22848 int32_t MakeDoors(int32_t map, int32_t scr)
1760 {
1761
2/2
✓ Branch 0 taken 18423 times.
✓ Branch 1 taken 4425 times.
22848 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1762 {
1763 18423 return 0;
1764 }
1765
1766 DoorComboSet tempdcs;
1767 4425 memset(&tempdcs, 0, sizeof(DoorComboSet));
1768
1769 //up
1770
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1771 {
1772
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1773 {
1774 159300 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1775 159300 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1776 159300 }
1777 39825 }
1778
1779 4425 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1780 4425 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1781 4425 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1782 4425 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1783 4425 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1784 4425 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1785
1786 //down
1787
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1788 {
1789
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1790 {
1791 159300 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1792 159300 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1793 159300 }
1794 39825 }
1795
1796 4425 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1797
1798 4425 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1799 4425 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1800 4425 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1801 4425 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1802 4425 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1803
1804 //left
1805 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1806
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1807 {
1808
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1809 {
1810 238950 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1811 238950 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1812 238950 }
1813 39825 }
1814
1815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1816 {
1817 if((j!=2)&&(j!=3))
1818 {
1819 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1820 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1821 }
1822 }
1823
1824 4425 tempdcs.bombdoorcombo_l[0]=0;
1825 4425 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1826 4425 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1827 4425 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1828 4425 tempdcs.bombdoorcombo_l[2]=0;
1829 4425 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1830 4425 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1831 4425 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1832
1833 //right
1834
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1835 {
1836
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1837 {
1838 238950 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1839 238950 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1840 238950 }
1841 39825 }
1842
1843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1844 {
1845 if((j!=2)&&(j!=3))
1846 {
1847 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1848 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1849 }
1850 }
1851
1852 4425 tempdcs.bombdoorcombo_r[0]=0;
1853 4425 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1854 4425 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1855 4425 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1856 4425 tempdcs.bombdoorcombo_r[2]=0;
1857 4425 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1858 4425 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1859 4425 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1860
1861 int32_t k;
1862
1863
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 28922 times.
28970 for(k=0; k<door_combo_set_count; k++)
1864 {
1865
2/2
✓ Branch 0 taken 4377 times.
✓ Branch 1 taken 24545 times.
28922 if(DoorComboSets[k]==tempdcs)
1866 {
1867 4377 break;
1868 }
1869 24545 }
1870
1871
2/2
✓ Branch 0 taken 4377 times.
✓ Branch 1 taken 48 times.
4425 if(k==door_combo_set_count)
1872 {
1873 48 DoorComboSets[k]=tempdcs;
1874 48 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
1875 48 ++door_combo_set_count;
1876 48 }
1877
1878 4425 return k;
1879 /*
1880 doorcombo_u[9][4];
1881 doorcset_u[9][4];
1882 doorcombo_d[9][4];
1883 doorcset_d[9][4];
1884 doorcombo_l[9][6];
1885 doorcset_l[9][6];
1886 doorcombo_r[9][6];
1887 doorcset_r[9][6];
1888 bombdoorcombo_u[2];
1889 bombdoorcset_u[2];
1890 bombdoorcombo_d[2];
1891 bombdoorcset_d[2];
1892 bombdoorcombo_l[3];
1893 bombdoorcset_l[3];
1894 bombdoorcombo_r[3];
1895 bombdoorcset_r[3];
1896 walkthroughcombo[4];
1897 walkthroughcset[4];
1898 */
1899 22848 }
1900
1901 2924544 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1902 {
1903 2924544 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1904 }
1905
1906 2924544 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1907 {
1908
1909 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1910 }
1911
1912 2924544 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1913 {
1914 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1915 }
1916
1917
1918 83 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1919 {
1920 char temp_pwd[30];
1921 83 memset(temp_pwd,0,30);
1922
1923
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 8 times.
83 if(pwdkey!=0)
1924 {
1925 75 memcpy(temp_pwd,encrypted_pwd,30);
1926 75 temp_pwd[29]=0;
1927
1928
2/2
✓ Branch 0 taken 2250 times.
✓ Branch 1 taken 75 times.
2325 for(int32_t i=0; i<30; i++)
1929 {
1930 2250 temp_pwd[i] -= pwdkey;
1931 2250 int32_t t=pwdkey>>15;
1932 2250 pwdkey = (pwdkey<<1)+t;
1933 2250 }
1934 75 }
1935
1936 83 memcpy(pwd,temp_pwd,30);
1937 83 }
1938
1939
1940 267 bool devpwd()
1941 {
1942 #ifdef _DEBUG
1943 return true;
1944 #endif
1945 #if DEVLEVEL > 3
1946 return true;
1947 #endif
1948
1/2
✓ Branch 0 taken 267 times.
✗ Branch 1 not taken.
267 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio) || is_ci();
1949 }
1950 bool check_questpwd(zquestheader *Header, char *pwd)
1951 {
1952 if(devpwd())
1953 return true;
1954 if((!strcmp(pwd, (char*)clavio)))
1955 return true;
1956 cvs_MD5Context ctx;
1957 uint8_t md5sum[16];
1958
1959 cvs_MD5Init(&ctx);
1960 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
1961 cvs_MD5Final(md5sum, &ctx);
1962
1963 return (memcmp(Header->pwd_hash,md5sum,16)==0);
1964 }
1965
1966 static char const* key_exts[KEYFILE_NUMTY] = {"key", "zcheat", "zpwd"};
1967 static bool key_hashed[KEYFILE_NUMTY] = {false, true, false};
1968 static char const* key_namestr[KEYFILE_NUMTY] = {"Master","Cheat","ZPwd"};
1969
1970 static bool check_keyfile(char const* path, char const* ext, bool hashed, char const* typestr, zquestheader* Header)
1971 {
1972 char keyfilename[2048];
1973 replace_extension(keyfilename, path, ext, 2047);
1974 if(!exists(keyfilename))
1975 return false;
1976 bool ret = false;
1977
1978 char password[QSTPWD_LEN] = {0}, pwd[32] = {0};
1979 PACKFILE *fp = pack_fopen_password(keyfilename, F_READ,"");
1980 char msg[80] = {0};
1981 pfread(msg, 80, fp);
1982 if(strcmp(msg,"ZQuest Auto-Generated Quest Password Key File. DO NOT EDIT!"))
1983 {
1984 zprint2("Found %s Key File '%s' (invalid header)\n", typestr, keyfilename);
1985 pack_fclose(fp);
1986 return false;
1987 }
1988 int16_t ver;
1989 byte bld;
1990 p_igetw(&ver, fp);
1991 p_getc(&bld, fp);
1992 pfread(password, QSTPWD_LEN, fp, true);
1993 if(hashed)
1994 {
1995 char unhashed_pw[QSTPWD_LEN] = {0};
1996
1997 char hashmap = 'Z';
1998 hashmap += 'Q';
1999 hashmap += 'U';
2000 hashmap += 'E';
2001 hashmap += 'S';
2002 hashmap += 'T';
2003
2004 for ( int32_t q = 0; q < QSTPWD_LEN; ++q )
2005 unhashed_pw[q] = password[q] - hashmap;
2006
2007 ret = check_questpwd(Header, unhashed_pw);
2008 }
2009 else ret = check_questpwd(Header, password);
2010 pack_fclose(fp);
2011 zprint2("Found %s Key File '%s' (%s access)\n",
2012 typestr, keyfilename, ret ? "valid" : "invalid");
2013 return ret;
2014 }
2015
2016 bool check_keyfiles(char const* path, vector<uint> types, zquestheader* Header)
2017 {
2018 char exedir[PATH_MAX] = {0};
2019 extract_name(path, exedir, FILENAMEALL);
2020 char const* paths[] = {path, exedir};
2021 for(uint keyty : types)
2022 {
2023 if(keyty >= KEYFILE_NUMTY)
2024 continue;
2025 for(char const* p : paths)
2026 {
2027 if(check_keyfile(p, key_exts[keyty], key_hashed[keyty], key_namestr[keyty], Header))
2028 return true;
2029 }
2030 }
2031 return false;
2032 }
2033
2034 380 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2035 {
2036 380 zprint2("\n");
2037 380 zprint2("[QUEST METADATA]\n");
2038
2/2
✓ Branch 0 taken 371 times.
✓ Branch 1 taken 9 times.
380 if(qst_num < moduledata.max_quest_files)
2039 9 zprint2("Loading module quest %d\n", qst_num+1);
2040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 380 times.
380 if(path) zprint2("Loading '%s'\n", path);
2041 380 zprint2("Last saved in version %s\n", tempheader.getVerStr());
2042
2043
2/2
✓ Branch 0 taken 243 times.
✓ Branch 1 taken 137 times.
380 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2044
2/2
✓ Branch 0 taken 243 times.
✓ Branch 1 taken 137 times.
380 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2045
2/2
✓ Branch 0 taken 243 times.
✓ Branch 1 taken 137 times.
380 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2046
2/2
✓ Branch 0 taken 243 times.
✓ Branch 1 taken 137 times.
380 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2047
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 366 times.
380 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2048
2/2
✓ Branch 0 taken 243 times.
✓ Branch 1 taken 137 times.
380 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2049 380 zprint2("\n");
2050 380 }
2051
2052 693 int32_t readheader(PACKFILE *f, zquestheader *Header, byte printmetadata)
2053 {
2054 int32_t dummy;
2055 zquestheader tempheader;
2056 char dummybuf[80];
2057 byte temp_map_count;
2058 byte temp_midi_flags[MIDIFLAGS_SIZE];
2059 word version;
2060 char temp_pwd[30], temp_pwd2[30];
2061 int16_t temp_pwdkey;
2062 cvs_MD5Context ctx;
2063 693 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2064 693 memset(&tempheader, 0, sizeof(tempheader));
2065 693 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2066
2067
2068
2069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
693 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f)) // first read old header
2070 {
2071 Z_message("Unable to read header string\n");
2072 return qe_invalid;
2073 }
2074
2075 // check header
2076
2/2
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 24 times.
693 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2077 {
2078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
2079 {
2080 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2081 return qe_invalid;
2082 }
2083 24 }
2084
2085 693 int32_t templatepath_len=0;
2086
2087 693 tempheader.external_zinfo = false;
2088 693 read_zinfo = false;
2089
2/2
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 24 times.
693 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2090 {
2091 byte padding;
2092
2093
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&padding,f))
2094 {
2095 return qe_invalid;
2096 }
2097
2098
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&tempheader.zelda_version,f))
2099 {
2100 return qe_invalid;
2101 }
2102
2103 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2104
2105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(tempheader.zelda_version > ZELDA_VERSION)
2106 {
2107 return qe_version;
2108 }
2109
2110 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2111
2112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
2113 {
2114 return qe_invalid;
2115 }
2116
2117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(bad_version(tempheader.zelda_version))
2118 {
2119 return qe_obsolete;
2120 }
2121
2122
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&tempheader.internal,f))
2123 {
2124 return qe_invalid;
2125 }
2126
2127
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.quest_number,f))
2128 {
2129 return qe_invalid;
2130 }
2131
2132 24 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2133
2134
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(&quest_rules[0],2,f))
2135 {
2136 return qe_invalid;
2137 }
2138
2139
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&temp_map_count,f))
2140 {
2141 return qe_invalid;
2142 }
2143
2144 24 FFCore.quest_format[qMapCount] = temp_map_count;
2145
2146
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.old_str_count,f))
2147 {
2148 return qe_invalid;
2149 }
2150
2151
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2152 {
2153 return qe_invalid;
2154 }
2155
2156
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(temp_midi_flags,4,f))
2157 {
2158 return qe_invalid;
2159 }
2160
2161
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2162 {
2163 return qe_invalid;
2164 }
2165
2166
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(dummybuf,14,f))
2167 {
2168 return qe_invalid;
2169 }
2170
2171
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(&quest_rules[2],2,f))
2172 {
2173 return qe_invalid;
2174 }
2175
2176
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&dummybuf,f))
2177 {
2178 return qe_invalid;
2179 }
2180
2181
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.version,9,f))
2182 {
2183 return qe_invalid;
2184 }
2185
2186
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2187 {
2188 return qe_invalid;
2189 }
2190 // These fields are expected to end in null bytes!
2191 24 tempheader.title[sizeof(tempheader.title)-1] = 0;
2192
2193
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2194 {
2195 return qe_invalid;
2196 }
2197 24 tempheader.author[sizeof(tempheader.author)-1] = 0;
2198
2199
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&padding,f))
2200 {
2201 return qe_invalid;
2202 }
2203
2204
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&temp_pwdkey,f))
2205 {
2206 return qe_invalid;
2207 }
2208
2209
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(temp_pwd,30,f))
2210 {
2211 return qe_invalid;
2212 }
2213
2214 24 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2215 24 cvs_MD5Init(&ctx);
2216 24 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2217 24 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2218
2219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2220 {
2221 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2222 // Not anymore...
2223 memset(tempheader.minver,0,17);
2224 tempheader.build=0;
2225 tempheader.use_keyfile=0;
2226 memset(tempheader.old_foo, 0, 9);
2227 }
2228 else
2229 {
2230
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.minver,9,f))
2231 {
2232 return qe_invalid;
2233 }
2234
2235
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.build,f))
2236 {
2237 return qe_invalid;
2238 }
2239
2240 24 FFCore.quest_format[vBuild] = tempheader.build;
2241
2242
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.use_keyfile,f))
2243 {
2244 return qe_invalid;
2245 }
2246
2247
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(dummybuf,9,f))
2248 {
2249 return qe_invalid;
2250 }
2251 } // starting at minver
2252
2253
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
24 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2254 {
2255 6 memset(&quest_rules[4],0,16); // word rules3..rules10
2256 6 }
2257 else
2258 {
2259
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!pfread(&quest_rules[4],16,f)) // read new header additions
2260 {
2261 return qe_invalid; // starting at rules3
2262 }
2263
2264
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 if(tempheader.zelda_version <= 0x190)
2265 {
2266 12 set_qr(qr_MEANPLACEDTRAPS,0);
2267 12 }
2268 }
2269 24 unpack_qrs();
2270
2271
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((tempheader.zelda_version < 0x192)||
2272
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2273 {
2274 18 set_qr(qr_BRKNSHLDTILES,(get_qr(qr_BRKBLSHLDS_DEP)));
2275 18 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2276 18 set_qr(qr_BRKBLSHLDS_DEP,1);
2277 18 }
2278
2279
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2280 {
2281 6 byte *mf=temp_midi_flags;
2282
2283
3/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4 times.
6 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2284 {
2285 4 mf=(byte*)dummybuf;
2286 4 }
2287
2288
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!pfread(mf,32,f)) // read new header additions
2289 {
2290 return qe_invalid; // starting at foo2
2291 }
2292
2293
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!pfread(dummybuf,18,f)) // read new header additions
2294 {
2295 return qe_invalid; // starting at foo2
2296 }
2297 6 }
2298
2299
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((tempheader.zelda_version < 0x192)||
2300
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2301 {
2302 18 memset(tempheader.templatepath,0,2048);
2303 18 }
2304 else
2305 {
2306
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!pfread(tempheader.templatepath,280,f)) // read templatepath
2307 {
2308 return qe_invalid;
2309 }
2310 }
2311
2312
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2313
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2314 {
2315 24 tempheader.use_keyfile=0;
2316 24 }
2317 24 }
2318 else
2319 {
2320 //section id
2321
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_mgetl(&dummy,f))
2322 {
2323 return qe_invalid;
2324 }
2325
2326 //section version info
2327
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&version,f))
2328 {
2329 return qe_invalid;
2330 }
2331
2332 669 FFCore.quest_format[vHeader] = version;
2333
2334
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&dummy,f))
2335 {
2336 return qe_invalid;
2337 }
2338
2339 //section size
2340
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetl(&dummy,f))
2341 {
2342 return qe_invalid;
2343 }
2344
2345 //finally... section data
2346
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&tempheader.zelda_version,f))
2347 {
2348 return qe_invalid;
2349 }
2350
2351 669 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2352
2353 //do some quick checking...
2354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
669 if(tempheader.zelda_version > ZELDA_VERSION)
2355 {
2356 return qe_version;
2357 }
2358
2359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
669 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2360 {
2361 return qe_invalid;
2362 }
2363
2364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
669 if(bad_version(tempheader.zelda_version))
2365 {
2366 return qe_obsolete;
2367 }
2368
2369
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_getc(&tempheader.build,f))
2370 {
2371 return qe_invalid;
2372 }
2373
2374 669 FFCore.quest_format[vBuild] = tempheader.build;
2375
2376
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 610 times.
669 if(version<3)
2377 {
2378
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!pfread(temp_pwd,30,f))
2379 {
2380 return qe_invalid;
2381 }
2382
2383
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_igetw(&temp_pwdkey,f))
2384 {
2385 return qe_invalid;
2386 }
2387
2388 59 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2389 59 cvs_MD5Init(&ctx);
2390 59 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2391 59 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2392 59 }
2393 else
2394 {
2395
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f))
2396 {
2397 return qe_invalid;
2398 }
2399 }
2400
2401
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&tempheader.internal,f))
2402 {
2403 return qe_invalid;
2404 }
2405
2406
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_getc(&tempheader.quest_number,f))
2407 {
2408 return qe_invalid;
2409 }
2410
2411 669 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2412
2413 669 size_t versz = version < 8 ? 9 : 16;
2414
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!pfread(tempheader.version,versz,f))
2415 {
2416 return qe_invalid;
2417 }
2418
2419 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2420 //needs to be copied as char[9] or stored as a s.str
2421
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!pfread(tempheader.minver,versz,f))
2422 {
2423 return qe_invalid;
2424 }
2425
2426 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2427
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2428 {
2429 return qe_invalid;
2430 }
2431 669 tempheader.title[sizeof(tempheader.title)-1] = 0;
2432
2433
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2434 {
2435 return qe_invalid;
2436 }
2437 669 tempheader.author[sizeof(tempheader.author)-1] = 0;
2438
2439
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_getc(&tempheader.use_keyfile,f))
2440 {
2441 return qe_invalid;
2442 }
2443
2444 /*
2445 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f))
2446 {
2447 return qe_invalid;
2448 }
2449 */
2450
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2451 {
2452 return qe_invalid;
2453 }
2454
2455
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!pfread(&dummybuf,4,f))
2456 {
2457 return qe_invalid;
2458 }
2459
2460
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2461 {
2462 return qe_invalid;
2463 }
2464
2465
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!pfread(dummybuf,14,f))
2466 {
2467 return qe_invalid;
2468 }
2469
2470 669 templatepath_len=sizeof(tempheader.templatepath);
2471
2472
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 59 times.
669 if(version==1)
2473 {
2474 59 templatepath_len=280;
2475 59 }
2476
2477
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!pfread(tempheader.templatepath,templatepath_len,f))
2478 {
2479 return qe_invalid;
2480 }
2481
2482
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_getc(&temp_map_count,f))
2483 {
2484 return qe_invalid;
2485 }
2486
2487
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 248 times.
669 if(version>=4)
2488 {
2489
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_igetl(&tempheader.version_major,f))
2490 {
2491 return qe_invalid;
2492 }
2493
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_igetl(&tempheader.version_minor,f))
2494 {
2495 return qe_invalid;
2496 }
2497
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_igetl(&tempheader.version_patch,f))
2498 {
2499 return qe_invalid;
2500 }
2501
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_igetl(&tempheader.new_version_id_fourth,f))
2502 {
2503 return qe_invalid;
2504 }
2505
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_igetl(&tempheader.new_version_id_alpha,f))
2506 {
2507 return qe_invalid;
2508 }
2509
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_igetl(&tempheader.new_version_id_beta,f))
2510 {
2511 return qe_invalid;
2512 }
2513
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_igetl(&tempheader.new_version_id_gamma,f))
2514 {
2515 return qe_invalid;
2516 }
2517
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_igetl(&tempheader.new_version_id_release,f))
2518 {
2519 return qe_invalid;
2520 }
2521
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_igetw(&tempheader.new_version_id_date_year,f))
2522 {
2523 return qe_invalid;
2524 }
2525
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_getc(&tempheader.new_version_id_date_month,f))
2526 {
2527 return qe_invalid;
2528 }
2529
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_getc(&tempheader.new_version_id_date_day,f))
2530 {
2531 return qe_invalid;
2532 }
2533
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_getc(&tempheader.new_version_id_date_hour,f))
2534 {
2535 return qe_invalid;
2536 }
2537
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_getc(&tempheader.new_version_id_date_minute,f))
2538 {
2539 return qe_invalid;
2540 }
2541
2542
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!pfread(tempheader.new_version_devsig,256,f))
2543 {
2544 return qe_invalid;
2545 }
2546
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2547 strcpy(tempheader.new_version_devsig, "EmilyV99");
2548
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!pfread(tempheader.new_version_compilername,256,f))
2549 {
2550 return qe_invalid;
2551 }
2552
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!pfread(tempheader.new_version_compilerversion,256,f))
2553 {
2554 return qe_invalid;
2555 }
2556
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!pfread(tempheader.product_name,1024,f))
2557 {
2558 return qe_invalid;
2559 }
2560
2561
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_getc(&tempheader.compilerid,f))
2562 {
2563 return qe_invalid;
2564 }
2565
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_igetl(&tempheader.compilerversionnumber_first,f))
2566 {
2567 return qe_invalid;
2568 }
2569
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_igetl(&tempheader.compilerversionnumber_second,f))
2570 {
2571 return qe_invalid;
2572 }
2573
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_igetl(&tempheader.compilerversionnumber_third,f))
2574 {
2575 return qe_invalid;
2576 }
2577
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f))
2578 {
2579 return qe_invalid;
2580 }
2581
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_igetw(&tempheader.developerid,f))
2582 {
2583 return qe_invalid;
2584 }
2585
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!pfread(tempheader.made_in_module_name,1024,f))
2586 {
2587 return qe_invalid;
2588 }
2589
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!pfread(tempheader.build_datestamp,256,f))
2590 {
2591 return qe_invalid;
2592 }
2593
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!pfread(tempheader.build_timestamp,256,f))
2594 {
2595 return qe_invalid;
2596 }
2597 421 }
2598 else // <4
2599 {
2600 248 tempheader.version_major = 0;
2601 248 tempheader.version_minor = 0;
2602 248 tempheader.version_patch = 0;
2603 248 tempheader.new_version_id_fourth = 0;
2604 248 tempheader.new_version_id_alpha = 0;
2605 248 tempheader.new_version_id_beta = 0;
2606 248 tempheader.new_version_id_gamma = 0;
2607 248 tempheader.new_version_id_release = 0;
2608 248 tempheader.new_version_id_date_year = 0;
2609 248 tempheader.new_version_id_date_month = 0;
2610 248 tempheader.new_version_id_date_day = 0;
2611 248 tempheader.new_version_id_date_hour = 0;
2612 248 tempheader.new_version_id_date_minute = 0;
2613
2614 248 memset(tempheader.new_version_devsig, 0, 256);
2615 248 memset(tempheader.new_version_compilername, 0, 256);
2616 248 memset(tempheader.new_version_compilerversion, 0, 256);
2617 248 memset(tempheader.product_name, 0, 1024);
2618 248 strcpy(tempheader.product_name, "ZQuest Classic");
2619
2620 248 tempheader.compilerid = 0;
2621 248 tempheader.compilerversionnumber_first = 0;
2622 248 tempheader.compilerversionnumber_second = 0;
2623 248 tempheader.compilerversionnumber_third = 0;
2624 248 tempheader.compilerversionnumber_fourth = 0;
2625 248 tempheader.developerid = 0;
2626
2627 248 memset(tempheader.made_in_module_name, 0, 1024);
2628 248 memset(tempheader.build_datestamp, 0, 256);
2629 248 memset(tempheader.build_timestamp, 0, 256);
2630 }
2631
2632
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 248 times.
669 if ( version >= 5 )
2633 {
2634
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!pfread(tempheader.build_timezone,6,f))
2635 {
2636 return qe_invalid;
2637 }
2638 421 }
2639 else // < 5
2640 {
2641 248 memset(tempheader.build_timezone, 0, 6);
2642 }
2643
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 421 times.
669 if ( version >= 6 )
2644 {
2645 byte b;
2646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
421 if(!p_getc(&b,f))
2647 {
2648 return qe_invalid;
2649 }
2650 421 tempheader.external_zinfo = b?true:false;
2651 421 read_zinfo = true;
2652 421 }
2653
2654
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 248 times.
669 if(version >= 7)
2655 {
2656
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_getc(&(tempheader.new_version_is_nightly),f))
2657 {
2658 return qe_invalid;
2659 }
2660 421 }
2661 else
2662 {
2663 248 tempheader.new_version_is_nightly = false;
2664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
248 if(tempheader.zelda_version < 0x255)
2665 {
2666
2/5
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 189 times.
✗ Branch 4 not taken.
248 switch(tempheader.zelda_version)
2667 {
2668 case 0x254:
2669 tempheader.version_major = 2;
2670 tempheader.version_minor = 54;
2671 break;
2672 case 0x250:
2673
7/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 28 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 24 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 81 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 16 times.
✓ Branch 14 taken 19 times.
✓ Branch 15 taken 15 times.
189 switch(tempheader.build)
2674 {
2675 case 19:
2676 tempheader.version_major = 2;
2677 tempheader.version_minor = 50;
2678 tempheader.new_version_id_gamma = 1;
2679 break;
2680 case 20:
2681 tempheader.version_major = 2;
2682 tempheader.version_minor = 50;
2683 tempheader.new_version_id_gamma = 2;
2684 break;
2685 case 21:
2686 tempheader.version_major = 2;
2687 tempheader.version_minor = 50;
2688 tempheader.new_version_id_gamma = 3;
2689 break;
2690 case 22:
2691 tempheader.version_major = 2;
2692 tempheader.version_minor = 50;
2693 tempheader.new_version_id_gamma = 4;
2694 break;
2695 case 23:
2696 tempheader.version_major = 2;
2697 tempheader.version_minor = 50;
2698 tempheader.new_version_id_gamma = 5;
2699 break;
2700 case 24:
2701 28 tempheader.version_major = 2;
2702 28 tempheader.version_minor = 50;
2703 28 tempheader.new_version_id_release = -1;
2704 28 break;
2705 case 25:
2706 tempheader.version_major = 2;
2707 tempheader.version_minor = 50;
2708 tempheader.version_patch = 1;
2709 tempheader.new_version_id_gamma = 1;
2710 break;
2711 case 26:
2712 24 tempheader.version_major = 2;
2713 24 tempheader.version_minor = 50;
2714 24 tempheader.version_patch = 1;
2715 24 tempheader.new_version_id_gamma = 2;
2716 24 break;
2717 case 27:
2718 tempheader.version_major = 2;
2719 tempheader.version_minor = 50;
2720 tempheader.version_patch = 1;
2721 tempheader.new_version_id_gamma = 3;
2722 break;
2723 case 28:
2724 6 tempheader.version_major = 2;
2725 6 tempheader.version_minor = 50;
2726 6 tempheader.version_patch = 1;
2727 6 tempheader.new_version_id_release = -1;
2728 6 break;
2729 case 29:
2730 81 tempheader.version_major = 2;
2731 81 tempheader.version_minor = 50;
2732 81 tempheader.version_patch = 2;
2733 81 tempheader.new_version_id_release = -1;
2734 81 break;
2735 case 30:
2736 tempheader.version_major = 2;
2737 tempheader.version_minor = 50;
2738 tempheader.version_patch = 3;
2739 tempheader.new_version_id_gamma = 1;
2740 break;
2741 case 31:
2742 16 tempheader.version_major = 2;
2743 16 tempheader.version_minor = 53;
2744 16 tempheader.new_version_id_gamma = -1;
2745 16 break;
2746 case 32:
2747 19 tempheader.version_major = 2;
2748 19 tempheader.version_minor = 53;
2749 19 tempheader.new_version_id_release = -1;
2750 19 break;
2751 case 33:
2752 15 tempheader.version_major = 2;
2753 15 tempheader.version_minor = 53;
2754 15 tempheader.version_patch = 1;
2755 15 break;
2756 }
2757 189 break;
2758
2759 case 0x211:
2760 tempheader.version_major = 2;
2761 tempheader.version_minor = 11;
2762 tempheader.new_version_id_beta = tempheader.build;
2763 break;
2764 case 0x210:
2765 59 tempheader.version_major = 2;
2766 59 tempheader.version_minor = 10;
2767 59 tempheader.new_version_id_beta = tempheader.build;
2768 59 break;
2769 }
2770 248 }
2771 }
2772
2773
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 565 times.
669 if (version>=9)
2774 {
2775 104 std::string version_string;
2776
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_getcstr(&version_string, f))
2777 {
2778 return qe_invalid;
2779 }
2780
2781 104 strncpy(tempheader.zelda_version_string, version_string.c_str(), sizeof(tempheader.zelda_version_string));
2782 104 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%s", version_string.c_str());
2783
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
104 }
2784 else
2785 {
2786 565 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%d.%d.%d", tempheader.version_major, tempheader.version_minor, tempheader.version_patch);
2787 }
2788
2789
3/4
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 660 times.
669 if(printmetadata || __isZQuest)
2790 {
2791 9 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2792 9 }
2793 }
2794
2795 //{ Version Warning
2796 693 int32_t vercmp = tempheader.compareVer();
2797 693 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), getAlphaState());
2798 693 int32_t avercmp = compare(tempheader.getAlphaVer(), 0);
2799
4/6
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 589 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 104 times.
797 if(vercmp > 0 || (!vercmp &&
2800
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 (astatecmp > 0 || (!astatecmp &&
2801 104 avercmp > 0))))
2802 {
2803 bool r = true;
2804 if(loadquest_report)
2805 {
2806 enter_sys_pal();
2807 AlertDialog("Quest saved in newer version",
2808 "This quest was last saved in a newer version of ZQuest."
2809 " Attempting to load this quest may not work correctly; to"
2810 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2811 "\n\nWould you like to continue loading anyway? (Not recommended)",
2812 [&](bool ret,bool)
2813 {
2814 r = ret;
2815 }).show();
2816 exit_sys_pal();
2817 }
2818 if(!r)
2819 return qe_silenterr;
2820 }
2821
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 else if(tempheader.compareDate() > 0)
2822 {
2823 bool r = true;
2824 if(loadquest_report)
2825 {
2826 enter_sys_pal();
2827 AlertDialog("Quest saved in newer build",
2828 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
2829 " issues loading in this build."
2830 "\n{}"
2831 "\n\nWould you like to continue loading anyway?",
2832 tempheader.getVerCmpStr()),
2833 [&](bool ret,bool)
2834 {
2835 r = ret;
2836 }).show();
2837 exit_sys_pal();
2838 }
2839 if(!r)
2840 return qe_silenterr;
2841 }
2842 //}
2843
2844 693 read_ext_zinfo = tempheader.external_zinfo;
2845
2846 693 memcpy(Header, &tempheader, sizeof(tempheader));
2847 693 map_count=temp_map_count;
2848 693 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2849
2850 693 unpack_qrs();
2851
2852 693 return 0;
2853 693 }
2854
2855 690 int32_t readrules(PACKFILE *f, zquestheader *Header)
2856 {
2857
2/2
✓ Branch 0 taken 667 times.
✓ Branch 1 taken 23 times.
690 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_rules);
2858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 690 times.
690 if (should_skip)
2859 return 0;
2860
2861 int32_t dummy;
2862 zquestheader tempheader;
2863 690 word s_version=0;
2864 690 dword compatrule_version=0;
2865
2866 690 memcpy(&tempheader, Header, sizeof(tempheader));
2867
2868
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 669 times.
690 if(tempheader.zelda_version >= 0x193)
2869 {
2870 //section version info
2871
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&s_version,f))
2872 {
2873 return qe_invalid;
2874 }
2875
2876 669 FFCore.quest_format[vRules] = s_version;
2877
2878
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&dummy,f))
2879 {
2880 return qe_invalid;
2881 }
2882
2883
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 421 times.
669 if(s_version > 16)
2884 {
2885
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_igetl(&compatrule_version,f))
2886 {
2887 return qe_invalid;
2888 }
2889 421 }
2890 669 FFCore.quest_format[vCompatRule] = compatrule_version;
2891
2892 //section size
2893
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetl(&dummy,f))
2894 {
2895 return qe_invalid;
2896 }
2897
2898
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 421 times.
669 if ( s_version < 15 )
2899 {
2900 //finally... section data
2901
1/2
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
248 if(!pfread(quest_rules,QUESTRULES_SIZE,f))
2902 {
2903 return qe_invalid;
2904 }
2905 248 }
2906 else
2907 {
2908
2909
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f))
2910 {
2911 return qe_invalid;
2912 }
2913
2914 }
2915 669 }
2916
2917 //{ bunch of compat stuff
2918 690 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2919
2920 690 unpack_qrs();
2921
2922
2/2
✓ Branch 0 taken 608 times.
✓ Branch 1 taken 82 times.
690 if(s_version<2)
2923 {
2924 82 set_qr(14,0);
2925 82 set_qr(27,0);
2926 82 set_qr(28,0);
2927 82 set_qr(29,0);
2928 82 set_qr(30,0);
2929 82 set_qr(32,0);
2930 82 set_qr(36,0);
2931 82 set_qr(49,0);
2932 82 set_qr(50,0);
2933 82 set_qr(51,0);
2934 82 set_qr(68,0);
2935 82 set_qr(75,0);
2936 82 set_qr(76,0);
2937 82 set_qr(98,0);
2938 82 set_qr(110,0);
2939 82 set_qr(113,0);
2940 82 set_qr(116,0);
2941 82 set_qr(102,0);
2942 82 set_qr(132,0);
2943 82 }
2944
2945 //Now, do any updates...
2946
5/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 610 times.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 14 times.
690 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
2947 {
2948 94 set_qr(qr_SMOOTHVERTICALSCROLLING,1);
2949 94 set_qr(qr_REPLACEOPENDOORS, 1);
2950 94 set_qr(qr_OLDLENSORDER, 1);
2951 94 set_qr(qr_NOFAIRYGUYFIRES, 1);
2952 94 set_qr(qr_TRIGGERSREPEAT, 1);
2953 94 }
2954
2955
5/6
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 669 times.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 14 times.
706 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2956 {
2957 35 set_qr(qr_WALLFLIERS,1);
2958 35 }
2959
2960
5/6
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 669 times.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 14 times.
706 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
2961 {
2962 35 set_qr(qr_NOBOMBPALFLASH,1);
2963 35 }
2964
2965
5/6
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 669 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 18 times.
706 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2966 {
2967 39 set_qr(qr_NOSCROLLCONTINUE,1);
2968 39 }
2969
2970
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 82 times.
710 if(tempheader.zelda_version <= 0x210)
2971 {
2972 82 set_qr(qr_ARROWCLIP,1);
2973 82 }
2974
2975
2/2
✓ Branch 0 taken 627 times.
✓ Branch 1 taken 59 times.
686 if(tempheader.zelda_version == 0x210)
2976 {
2977 59 set_qr(qr_NOSCROLLCONTINUE, get_qr(qr_CMBCYCLELAYERS));
2978 59 set_qr(qr_CMBCYCLELAYERS, 0);
2979 59 set_qr(qr_CONT_SWORD_TRIGGERS, 1);
2980 59 }
2981
2982
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 82 times.
686 if(tempheader.zelda_version <= 0x210)
2983 {
2984 82 set_qr(qr_OLDSTYLEWARP,1);
2985 82 set_qr(qr_210_WARPRETURN,1);
2986 82 }
2987
2988 //might not be correct
2989
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 23 times.
686 if(tempheader.zelda_version < 0x210)
2990 {
2991 23 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
2992 23 set_qr(qr_OLDTRIBBLES_DEP,1);
2993 23 set_qr(qr_OLDHOOKSHOTGRAB,1);
2994 23 }
2995
2996
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 82 times.
686 if(tempheader.zelda_version < 0x211)
2997 {
2998 82 set_qr(qr_WRONG_BRANG_TRAIL_DIR,1);
2999 82 }
3000
3001
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 681 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 664 times.
686 if((tempheader.zelda_version == 0x192 && tempheader.build <= 163) || tempheader.zelda_version < 0x192)
3002 {
3003 22 set_qr(qr_192b163_WARP,1);
3004 22 }
3005
3006
2/2
✓ Branch 0 taken 627 times.
✓ Branch 1 taken 59 times.
686 if(tempheader.zelda_version == 0x210)
3007 {
3008 59 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
3009 59 set_qr(qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
3010 59 set_qr(qr_DMGCOMBOPRI, 0);
3011 59 }
3012
3013
5/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 610 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 18 times.
686 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3014 {
3015 94 set_qr(qr_OLDPICKUP,1);
3016 94 }
3017
3018
5/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 610 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 18 times.
710 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3019 {
3020 94 set_qr(qr_NOSOLIDDAMAGECOMBOS, 1);
3021 94 set_qr(qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3022 94 }
3023
3024
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 82 times.
710 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3025 {
3026 82 set_qr(qr_HOOKSHOTDOWNBUG, 1);
3027 82 }
3028
3029
4/4
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 497 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 28 times.
686 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3030 {
3031 28 set_qr(qr_PEAHATCLOCKVULN, 1);
3032 28 }
3033
3034
6/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 76 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 421 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 183 times.
686 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3035 {
3036 94 set_qr(qr_OLD_DOORREPAIR, 1);
3037 94 }
3038
3039
6/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 76 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 421 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 207 times.
686 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3040 {
3041 94 set_qr(qr_OLD_SECRETMONEY, 1);
3042 94 }
3043
3044
6/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 421 times.
✓ Branch 4 taken 46 times.
✓ Branch 5 taken 155 times.
710 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3045 {
3046 146 set_qr(qr_OLD_POTION_OR_HC, 1);
3047 146 }
3048
3049
6/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 421 times.
✓ Branch 4 taken 46 times.
✓ Branch 5 taken 155 times.
710 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3050 {
3051 146 set_qr(qr_OFFSCREENWEAPONS, 1);
3052 146 }
3053
3054 //Bombchu fix.
3055
2/2
✓ Branch 0 taken 521 times.
✓ Branch 1 taken 189 times.
710 if(tempheader.zelda_version == 0x250)
3056 {
3057
2/2
✓ Branch 0 taken 161 times.
✓ Branch 1 taken 28 times.
189 if ( tempheader.build == 24 ) //2.50.0
3058 {
3059 28 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3060 28 }
3061
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 6 times.
189 if ( tempheader.build == 28 ) //2.50.1
3062 {
3063 6 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3064 6 }
3065
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 81 times.
189 if ( tempheader.build == 29 ) //2.50.2
3066 {
3067 81 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3068 81 }
3069
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if ( tempheader.build == 30 ) //2.50.3RC1
3070 {
3071 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3072 }
3073 189 }
3074
3075
6/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 421 times.
✓ Branch 4 taken 52 times.
✓ Branch 5 taken 161 times.
710 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3076 {
3077 // qr_OFFSETEWPNCOLLISIONFIX
3078 // All 'official' quests need this disabled.
3079 // All 2.10 and lower quests need this enabled to preseve compatability.
3080 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3081
3082 //~Gleeok
3083 152 set_qr(qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3084
3085 // Broke in build 695
3086
3/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
152 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3087 58 set_qr(qr_BROKENSTATUES, 1);
3088 140 }
3089
11/14
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 674 times.
✓ Branch 2 taken 669 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 717 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 717 times.
✓ Branch 9 taken 5 times.
✓ Branch 10 taken 700 times.
✓ Branch 11 taken 22 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
722 if (tempheader.zelda_version <= 0x190 || (tempheader.zelda_version == 0x192 && std::string(tempheader.title).starts_with("Zelda 3000\0")))
3090 {
3091 22 set_qr(qr_COPIED_SWIM_SPRITES, 1);
3092 22 }
3093
9/10
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 533 times.
✓ Branch 2 taken 518 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 436 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 421 times.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 421 times.
722 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3094 {
3095 286 set_qr(qr_OLD_SLASHNEXT_SECRETS, 1);
3096 286 }
3097
3098
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 82 times.
692 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3099 {
3100 82 set_qr(qr_OLD_210_WATER, 1);
3101 82 }
3102
3103
4/6
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 421 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 421 times.
692 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3104 {
3105 271 set_qr(qr_STEP_IS_FLOAT,0);
3106 271 }
3107
3108
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 82 times.
692 if ( tempheader.zelda_version < 0x250 )
3109 {
3110 82 set_qr(qr_8WAY_SHOT_SFX, 1);
3111 82 }
3112
3113
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 82 times.
692 if(s_version < 3)
3114 {
3115 82 set_qr(qr_HOLDNOSTOPMUSIC, 1);
3116 82 set_qr(qr_CAVEEXITNOSTOPMUSIC, 1);
3117 82 }
3118
3119
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 82 times.
692 if(s_version<4)
3120 {
3121 82 set_qr(10,0);
3122 82 }
3123
3124
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 82 times.
692 if(s_version<5)
3125 {
3126 82 set_qr(27,0);
3127 82 }
3128
3129
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 82 times.
692 if(s_version<6)
3130 {
3131 82 set_qr(46,0);
3132 82 }
3133
3134
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 82 times.
692 if(s_version<7) // January 2008
3135 {
3136 82 set_qr(qr_HEARTSREQUIREDFIX,0);
3137 82 set_qr(qr_PUSHBLOCKCSETFIX,1);
3138 82 }
3139
3140
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 610 times.
692 if(s_version<8)
3141 {
3142 82 set_qr(12, 0);
3143 82 }
3144 else
3145 {
3146 610 set_bit(deprecated_rules, 12, 0);
3147 }
3148
3149
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 82 times.
692 if(s_version<9) // October 2008
3150 {
3151 82 set_qr(qr_NOROPE2FLASH_DEP,0);
3152 82 set_qr(qr_NOBUBBLEFLASH_DEP,0);
3153 82 set_qr(qr_GHINI2BLINK_DEP,0);
3154 82 set_qr(qr_PHANTOMGHINI2_DEP,0);
3155 82 }
3156
3157
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 82 times.
692 if(s_version<10) // December 2008
3158 {
3159 82 set_qr(qr_NOCLOCKS_DEP,0);
3160 82 set_qr(qr_ALLOW10RUPEEDROPS_DEP,0);
3161 82 }
3162
3163
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 82 times.
692 if(s_version<11) // April 2009
3164 {
3165 82 set_qr(qr_SLOWENEMYANIM_DEP,0);
3166 82 }
3167
3168 // This served no purpose.
3169 // if(s_version<12) // December 2009
3170 // {
3171 // set_qr(qr_BRKBLSHLDS_DEP,0);
3172 // set_qr(qr_OLDTRIBBLES_DEP,0);
3173 // }
3174
3175 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3176
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 82 times.
692 if(s_version < 13)
3177 {
3178 82 set_qr(qr_SHOPCHEAT, 1);
3179 82 }
3180
3181 // Not entirely sure this is the best place for this...
3182 //2.50.2 bitmap offset fix
3183 692 memset(extra_rules, 0, EXTRARULES_SIZE);
3184
6/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 421 times.
✓ Branch 4 taken 58 times.
✓ Branch 5 taken 131 times.
692 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3185 {
3186 140 set_er(er_BITMAPOFFSET, 1);
3187 140 set_qr(qr_BITMAPOFFSETFIX, 1);
3188 140 }
3189 //required because quest templates also used this bit, although
3190 //it never did anything, before. -Z
3191
2/2
✓ Branch 0 taken 503 times.
✓ Branch 1 taken 189 times.
692 if ( tempheader.zelda_version == 0x250 )
3192 {
3193
5/6
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 108 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 92 times.
189 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3194 {
3195 97 set_er(er_BITMAPOFFSET, 0);
3196 97 set_qr(qr_BITMAPOFFSETFIX, 0);
3197 97 }
3198 189 }
3199
1/2
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
692 if ( tempheader.zelda_version == 0x254 )
3200 {
3201 set_er(er_BITMAPOFFSET, 0);
3202 set_qr(qr_BITMAPOFFSETFIX, 0);
3203 }
3204
3/4
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 421 times.
✗ Branch 3 not taken.
692 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3205 {
3206 set_er(er_BITMAPOFFSET, 0);
3207 set_qr(qr_BITMAPOFFSETFIX, 0);
3208 }
3209 //optimise fast drawing for older versions.
3210
4/6
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 421 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 421 times.
692 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3211 {
3212 271 set_qr(qr_OLDSPRITEDRAWS, 1);
3213 271 }
3214 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3215 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3216 //older quests can set the rule by hand. We need a new qst.dat again.
3217
4/6
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 421 times.
✓ Branch 3 taken 271 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 421 times.
692 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3218 {
3219 set_qr(qr_OLDEWPNPARENT, 1);
3220 }
3221
4/6
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 421 times.
✓ Branch 3 taken 271 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 421 times.
692 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3222 {
3223 set_qr(qr_OLDCREATEBITMAP_ARGS, 1);
3224 }
3225
4/6
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 421 times.
✓ Branch 3 taken 271 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 421 times.
692 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3226 {
3227 set_qr(qr_OLDQUESTMISC, 1);
3228 }
3229
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if ( tempheader.zelda_version < 0x254 )
3230 {
3231 271 set_qr(qr_OLDCREATEBITMAP_ARGS, 0);
3232 271 set_qr(qr_OLDEWPNPARENT, 0);
3233 271 set_qr(qr_OLDQUESTMISC, 0);
3234 271 }
3235
3236 //item scripts continue to run
3237
4/6
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 421 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 421 times.
692 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3238 {
3239 271 set_qr(qr_ITEMSCRIPTSKEEPRUNNING, 0);
3240 271 set_qr(qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3241 271 set_qr(qr_FIXSCRIPTSDURINGSCROLLING, 0);
3242 271 set_qr(qr_SCRIPTDRAWSINWARPS, 0);
3243 271 set_qr(qr_DYINGENEMYESDONTHURTHERO, 0);
3244 271 set_qr(qr_OUTOFBOUNDSENEMIES, 0);
3245 271 set_qr(qr_SPRITEXY_IS_FLOAT, 0);
3246 271 }
3247
3248
4/6
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 421 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 421 times.
692 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3249 {
3250 271 set_qr(qr_CLEARINITDONSCRIPTCHANGE, 1);
3251 271 }
3252
4/6
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 421 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 421 times.
692 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3253 {
3254 271 set_qr(qr_TRACESCRIPTIDS, 0);
3255 271 set_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3256 271 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3257 271 set_qr(qr_PARSER_250DIVISION,1);
3258 271 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL,1);
3259 271 set_qr(qr_PARSER_TRUE_INT_SIZE,0);
3260 271 set_qr(qr_PARSER_FORCE_INLINE,0);
3261 271 set_qr(qr_PARSER_BINARY_32BIT,0);
3262
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 7 times.
271 if ( get_qr(qr_SELECTAWPN) )
3263 {
3264 7 set_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3265 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3266 //Now they **do**, unless you disable that behaviour.
3267 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3268 //now enable the disable L/R item swap on load.
3269 7 }
3270
3271 271 }
3272
4/6
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 421 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 421 times.
692 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3273 {
3274 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3275 271 set_qr(qr_DISALLOW_SETTING_RAFTING, 1);
3276 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3277 //animations ending earlier than they should.
3278 271 set_qr(qr_BROKEN_ASKIP_Y_FRAMES, 1);
3279 //Enemies would ignore solidity on the top half of combos
3280 271 set_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3281 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3282 271 set_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3283 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3284 271 set_qr(qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3285 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3286 271 set_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3287 271 }
3288
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if ( tempheader.zelda_version < 0x255 )
3289 {
3290 271 set_qr(qr_NOFFCWAITDRAW, 1);
3291 271 set_qr(qr_NOITEMWAITDRAW, 1);
3292 271 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3293 271 set_qr(qr_OLD_INIT_SCRIPT_TIMING, 1);
3294 //set_qr(qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3295 271 }
3296
4/6
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 421 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 421 times.
692 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3297 {
3298 271 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3299 271 }
3300
4/6
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 421 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 421 times.
692 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3301 {
3302 271 set_qr(qr_OLD_PRINTF_ARGS, 1);
3303 271 }
3304
3305
3306
4/6
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 421 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 421 times.
692 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3307 {
3308 271 set_qr(qr_BROKEN_RING_POWER, 1);
3309 271 }
3310
4/6
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 421 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 421 times.
692 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3311 {
3312 271 set_qr(qr_NO_OVERWORLD_MAP_CHARTING, 1);
3313 271 }
3314
4/6
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 421 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 421 times.
692 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3315 {
3316 271 set_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3317 271 }
3318
4/6
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 421 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 421 times.
692 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3319 {
3320 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3321
1/2
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
271 if(get_qr(qr_SET_XBUTTON_ITEMS))
3322 set_qr(qr_SET_YBUTTON_ITEMS,1);
3323 271 }
3324
4/6
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 421 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 421 times.
692 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3325 {
3326 271 set_qr(qr_ALLOW_EDITING_COMBO_0,1);
3327 271 }
3328
4/6
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 421 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 421 times.
692 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3329 {
3330 271 set_qr(qr_OLD_CHEST_COLLISION,1);
3331 271 }
3332
3333
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if ( tempheader.zelda_version < 0x254 )
3334 {
3335 271 set_qr(qr_250WRITEEDEFSCRIPT, 1);
3336 271 }
3337 //Sideview spikes in 2.50.0
3338
6/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 421 times.
✓ Branch 4 taken 52 times.
✓ Branch 5 taken 137 times.
692 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3339 {
3340 134 set_qr(qr_OLDSIDEVIEWSPIKES, 1);
3341 134 }
3342 //more 2.50 fixes -Z
3343
6/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 421 times.
✓ Branch 4 taken 139 times.
✓ Branch 5 taken 50 times.
692 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3344 {
3345 221 set_qr(qr_MELEEMAGICCOST, 0);
3346 221 set_qr(qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3347 221 set_qr(qr_OLDMIRRORCOMBOS, 1);
3348 221 set_qr(qr_BROKENBOOKCOST, 1);
3349 221 set_qr(qr_BROKENCHARINTDRAWING, 1);
3350
3351 221 }
3352
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
692 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3353 {
3354 //set_qr(qr_MELEEMAGICCOST, get_er(er_MAGICCOSTSWORD));
3355 set_qr(qr_MELEEMAGICCOST, 1);
3356 }
3357
3358
2/2
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 23 times.
692 if(tempheader.zelda_version < 0x193)
3359 {
3360 23 set_qr(qr_SHORTDGNWALK, 1);
3361 23 }
3362
3363
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if(tempheader.zelda_version < 0x255)
3364 {
3365 271 set_qr(qr_OLDINFMAGIC, 1);
3366 271 }
3367
3368
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 82 times.
692 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3369 {
3370 82 set_qr(qr_SIDEVIEWTRIFORCECELLAR,1);
3371 82 }
3372
3373
4/6
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 421 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 421 times.
692 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3374 {
3375 271 set_qr(qr_OLD_F6,1);
3376 271 }
3377
4/6
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 421 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 421 times.
692 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3378 {
3379 271 set_qr(qr_NO_OVERWRITING_HOPPING,1);
3380 271 }
3381
4/6
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 421 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 421 times.
692 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3382 {
3383 271 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3384 271 }
3385
4/6
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 421 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 421 times.
692 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3386 {
3387 271 set_qr(qr_BROKEN_OVERWORLD_MINIMAP,1);
3388 271 }
3389 //}
3390
3391
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3392 271 set_qr(qr_ENEMIES_SECRET_ONLY_16_31,1);
3393
3394
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if(compatrule_version < 2) //Old CSet2 Handling
3395 271 set_qr(qr_OLDCS2,1);
3396
3397
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3398 271 set_qr(qr_HARDCODED_ENEMY_ANIMS,1);
3399
3400
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3401 271 set_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3402
3403
4/4
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 421 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 189 times.
692 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3404 189 set_qr(qr_NO_LANMOLA_RINGLEADER,1);
3405
3406
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3407 271 set_qr(qr_STEPTEMP_SECRET_ONLY_16_31,1);
3408
3409
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3410 271 set_qr(qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3411
3412
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3413 271 set_qr(qr_HARDCODED_LITEM_LTMS,1);
3414
3415
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if(compatrule_version < 9)
3416 {
3417 //Hardcoded BS Patras
3418 271 set_qr(qr_HARDCODED_BS_PATRA,1);
3419 //Hardcoded Patra Inner Eye offsets
3420 271 set_qr(qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3421 //Broken 'Big enemy' animation style
3422 271 set_qr(qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3423 //Broken Attribute 31/32
3424 271 set_qr(qr_BROKEN_ATTRIBUTE_31_32,1);
3425 271 }
3426
3427
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if(compatrule_version < 10) //Shared candle use limits
3428 271 set_qr(qr_CANDLES_SHARED_LIMIT,1);
3429
3430
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if(compatrule_version < 11) //No cross-screen return points
3431 271 set_qr(qr_OLD_RESPAWN_POINTS,1);
3432
3433
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if(compatrule_version < 12)
3434 {
3435 //Old fire trail duration
3436 271 set_qr(qr_OLD_FLAMETRAIL_DURATION,1);
3437 //Old Intro String in Ganon Room Behavior
3438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 271 times.
271 if(get_qr(qr_GANONINTRO)) set_qr(qr_GANONINTRO,0);
3439 271 else set_qr(qr_GANONINTRO,1);
3440 271 }
3441
3442
3/4
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 421 times.
✓ Branch 2 taken 271 times.
✗ Branch 3 not taken.
692 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3443 set_qr(qr_ANONE_NOANIM,1);
3444
3445
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if(compatrule_version < 14) //Old Bridge Combo Behavior
3446 271 set_qr(qr_OLD_BRIDGE_COMBOS,1);
3447
3448
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if(compatrule_version < 15) //Broken Z3 Animation
3449 271 set_qr(qr_BROKEN_Z3_ANIMATION,1);
3450
3451
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3452 271 set_qr(qr_OLD_TILE_INITIALIZATION,1);
3453
3454
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if(compatrule_version < 17)
3455 {
3456 //Old Quake/DrawYOffset behavior
3457 //set_qr(qr_OLD_DRAWOFFSET,1);
3458 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3459 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3460 271 }
3461
3462
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if(compatrule_version < 18)
3463 {
3464 //Broken DrawScreen Derivative Functions
3465 271 set_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3466 //Scrolling Cancels Charge
3467 271 set_qr(qr_SCROLLING_KILLS_CHARGE,1);
3468 271 }
3469
3470
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3471 271 set_qr(qr_BROKEN_ITEM_CARRYING,1);
3472
3473
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if(compatrule_version < 20)
3474 271 set_qr(qr_CUSTOMWEAPON_IGNORE_COST,1);
3475
3476
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if(compatrule_version < 21)
3477 {
3478 271 set_qr(qr_LEEVERS_DONT_OBEY_STUN,1);
3479 271 set_qr(qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3480 271 set_qr(qr_WIZZROBES_DONT_OBEY_STUN,1);
3481 271 set_qr(qr_OLD_BUG_NET,1);
3482 271 set_qr(qr_MANHANDLA_BLOCK_SFX,1);
3483 271 }
3484
3485
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if(compatrule_version < 22)
3486 271 set_qr(qr_BROKEN_KEEPOLD_FLAG,1);
3487
3488
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if(compatrule_version < 23)
3489 271 set_qr(qr_OLD_HALF_MAGIC,1);
3490
3491
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if(compatrule_version < 24)
3492 {
3493 271 set_qr(qr_WARPS_RESTART_DMAPSCRIPT,1);
3494 271 set_qr(qr_DMAP_0_CONTINUE_BUG,1);
3495 271 }
3496
3497
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if(compatrule_version < 25)
3498 {
3499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 271 times.
271 if (get_qr(qr_OLD_FAIRY_LIMIT)) set_qr(qr_OLD_FAIRY_LIMIT,0);
3500 271 else set_qr(qr_OLD_FAIRY_LIMIT,1);
3501 271 set_qr(qr_OLD_SCRIPTED_KNOCKBACK,1);
3502 271 }
3503
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if(compatrule_version < 26)
3504 {
3505 271 set_qr(qr_OLD_KEESE_Z_AXIS,1);
3506 271 set_qr(qr_POLVIRE_NO_SHADOW,1);
3507 271 set_qr(qr_SUBSCR_OLD_SELECTOR,1);
3508 271 }
3509
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3510 {
3511
2/2
✓ Branch 0 taken 81571 times.
✓ Branch 1 taken 271 times.
81842 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3512 81571 set_qr(q,0);
3513
2/2
✓ Branch 0 taken 813 times.
✓ Branch 1 taken 271 times.
1084 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < qr_MAX; ++q)
3514 813 set_qr(q,0);
3515 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3516 271 }
3517
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 276 times.
692 if(compatrule_version < 28)
3518 276 set_qr(qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3519
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 276 times.
692 if(compatrule_version < 29)
3520 276 set_qr(qr_OLD_LOCKBLOCK_COLLISION,1);
3521
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 276 times.
692 if(compatrule_version < 30)
3522 {
3523 276 set_qr(qr_DECO_2_YOFFSET,1);
3524 276 set_qr(qr_SCREENSTATE_80s_BUG,1);
3525 276 }
3526
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 276 times.
692 if(compatrule_version < 31)
3527 {
3528 276 set_qr(qr_GOHMA_UNDAMAGED_BUG,1);
3529 276 set_qr(qr_FFCPRELOAD_BUGGED_LOAD,1);
3530 276 }
3531
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 276 times.
692 if(compatrule_version < 32)
3532 276 set_qr(qr_BROKEN_GETPIXEL_VALUE,1);
3533
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 276 times.
692 if(compatrule_version < 33)
3534 276 set_qr(qr_NO_LIFT_SPRITE,1);
3535
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 276 times.
692 if(compatrule_version < 34)
3536 {
3537 276 set_qr(qr_OLD_SIDEVIEW_LANDING_CODE,1);
3538 276 set_qr(qr_OLD_FFC_SPEED_CAP,1);
3539 276 set_qr(qr_OLD_FFC_FUNCTIONALITY,1);
3540 276 set_qr(qr_OLD_WIZZROBE_SUBMERGING,1);
3541 276 }
3542
2/2
✓ Branch 0 taken 414 times.
✓ Branch 1 taken 278 times.
692 if(compatrule_version < 35)
3543 {
3544 278 set_qr(qr_ZS_NO_NEG_ARRAY,1);
3545 278 set_qr(qr_BROKEN_INPUT_DOWN_STATE,1);
3546 278 }
3547
2/2
✓ Branch 0 taken 414 times.
✓ Branch 1 taken 278 times.
692 if(compatrule_version < 36)
3548 278 set_qr(qr_OLD_SHALLOW_SFX,1);
3549
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 282 times.
692 if(compatrule_version < 37)
3550 282 set_qr(qr_SPARKLES_INHERIT_PROPERTIES,1);
3551
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 282 times.
692 if(compatrule_version < 38)
3552 282 set_qr(qr_BUGGED_LAYERED_FLAGS,1);
3553
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 282 times.
692 if(compatrule_version < 39)
3554 282 set_qr(qr_HARDCODED_FFC_BUSH_DROPS,1);
3555
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 282 times.
692 if(compatrule_version < 40)
3556 282 set_qr(qr_MOVINGBLOCK_FAKE_SOLID,1);
3557
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 284 times.
692 if(compatrule_version < 41)
3558 284 set_qr(qr_BROKENHITBY,1);
3559
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 284 times.
692 if(compatrule_version < 42)
3560 284 set_qr(qr_BROKEN_MOVING_BOMBS,1);
3561
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 284 times.
692 if(compatrule_version < 43)
3562 284 set_qr(qr_OLD_BOMB_HITBOXES,1);
3563
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 284 times.
692 if(compatrule_version < 44)
3564 284 set_qr(qr_SCROLLWARP_NO_RESET_FRAME,1);
3565
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 284 times.
692 if(compatrule_version < 45)
3566 284 set_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3567
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 284 times.
692 if(compatrule_version < 46)
3568 284 set_qr(qr_BROKEN_RAFT_SCROLL,1);
3569
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 289 times.
692 if(compatrule_version < 47)
3570 {
3571 289 set_qr(qr_SENSITIVE_SOLID_DAMAGE,1);
3572 289 set_qr(qr_OLD_CONVEYOR_COLLISION,1);
3573 289 }
3574
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 289 times.
692 if(compatrule_version < 48)
3575 289 set_qr(qr_OLD_GUY_HANDLING,1);
3576
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 289 times.
692 if(compatrule_version < 49)
3577 289 set_qr(qr_FAIRY_FLAG_COMPAT,1);
3578
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 289 times.
692 if(compatrule_version < 50)
3579 289 set_qr(qr_OLD_LENS_LAYEREFFECT,1);
3580
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 289 times.
692 if(compatrule_version < 51)
3581 289 set_qr(qr_PUSHBLOCK_SPRITE_LAYER,1);
3582
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 289 times.
692 if (compatrule_version < 52)
3583 289 set_qr(qr_OLD_SCRIPT_VOLUME, 1);
3584
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 289 times.
692 if(compatrule_version < 53)
3585 {
3586 289 set_qr(qr_OLD_SUBSCR,1);
3587 289 set_qr(qr_ITM_0_INVIS_ON_BTNS,1);
3588 289 set_qr(qr_OLD_GAUGE_TILE_LAYOUT,1);
3589 289 }
3590
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 289 times.
692 if(compatrule_version < 54)
3591 289 set_qr(qr_WALKTHROUGHWALL_NO_DOORSTATE,1);
3592
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 289 times.
692 if(compatrule_version < 55)
3593 289 set_qr(qr_SPOTLIGHT_IGNR_SOLIDOBJ,1);
3594
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 289 times.
692 if(compatrule_version < 56)
3595 289 set_qr(qr_BROKEN_LIGHTBEAM_HITBOX,1);
3596
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 289 times.
692 if(compatrule_version < 57)
3597 289 set_qr(qr_BROKEN_SWORD_SPIN_TRIGGERS,1);
3598
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 289 times.
692 if(compatrule_version < 58)
3599 289 set_qr(qr_OLD_DMAP_INTRO_STRINGS,1);
3600
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 289 times.
692 if(compatrule_version < 59)
3601 289 set_qr(qr_SCRIPT_CONTHP_IS_HEARTS,1);
3602
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 289 times.
692 if(compatrule_version < 60)
3603 289 set_qr(qr_SEPARATE_BOMBABLE_TAPPING_SFX,1);
3604
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 289 times.
692 if(compatrule_version < 61)
3605 289 set_qr(qr_BROKEN_BOMB_AMMO_COSTS,1);
3606
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 289 times.
692 if(compatrule_version < 62)
3607 289 set_qr(qr_OLD_BROKEN_WARPEX_MUSIC,1);
3608
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 289 times.
692 if(compatrule_version < 63)
3609 {
3610 289 set_qr(qr_BROKEN_LIFTSWIM,1);
3611 289 set_qr(qr_BROKEN_GENERIC_PUSHBLOCK_LOCKING,1);
3612 289 }
3613
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 289 times.
692 if(compatrule_version < 64)
3614 289 set_qr(qr_BROKEN_FLAME_ARROW_REFLECTING,1);
3615
2/2
✓ Branch 0 taken 379 times.
✓ Branch 1 taken 313 times.
692 if(compatrule_version < 65)
3616 313 set_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP,1);
3617
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 588 times.
692 if(compatrule_version < 66)
3618 588 set_qr(qr_NEWDARK_TRANS_STACKING,1);
3619
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 588 times.
692 if(compatrule_version < 67)
3620 588 set_qr(qr_OLD_HERO_WARP_RETSQUARE,1);
3621
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 654 times.
692 if(compatrule_version < 68)
3622 654 set_qr(qr_SCRIPTS_6_BIT_COLOR,1);
3623
3624 692 set_qr(qr_ANIMATECUSTOMWEAPONS,0);
3625
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 271 times.
692 if (s_version < 16)
3626 271 set_qr(qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3627
3628 692 memcpy(Header, &tempheader, sizeof(tempheader));
3629
3630 692 return 0;
3631 692 }
3632
3633 5805983 void init_msgstr(MsgStr *str)
3634 {
3635 5805983 str->s = "";
3636 5805983 str->s.shrink_to_fit();
3637 5805983 str->nextstring=0;
3638 5805983 str->tile=0;
3639 5805983 str->cset=0;
3640 5805983 str->trans=false;
3641 5805983 str->font=font_zfont;
3642 5805983 str->y=32;
3643 5805983 str->sfx=18;
3644 5805983 str->listpos=0;
3645 5805983 str->x=24;
3646 5805983 str->w=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3647 5805983 str->h=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3648 5805983 str->hspace=0;
3649 5805983 str->vspace=0;
3650 5805983 str->stringflags=0;
3651 5805983 str->margins[up] = 8;
3652 5805983 str->margins[down] = 0;
3653 5805983 str->margins[left] = 8;
3654 5805983 str->margins[right] = 8;
3655 5805983 str->portrait_tile = 0;
3656 5805983 str->portrait_cset = 0;
3657 5805983 str->portrait_x = 0;
3658 5805983 str->portrait_y = 0;
3659 5805983 str->portrait_tw = 1;
3660 5805983 str->portrait_th = 1;
3661 5805983 str->shadow_type = 0;
3662 5805983 str->shadow_color = 0;
3663 5805983 str->drawlayer = 6;
3664 5805983 }
3665
3666 692 void init_msgstrings(int32_t start, int32_t end)
3667 {
3668
2/4
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 692 times.
692 if(end <= start || end-start > msg_strings_size)
3669 return;
3670
3671
2/2
✓ Branch 0 taken 5668864 times.
✓ Branch 1 taken 692 times.
5669556 for(int32_t i=start; i<end; i++)
3672 {
3673 5668864 init_msgstr(&MsgStrings[i]);
3674 5668864 MsgStrings[i].listpos=i;
3675 5668864 }
3676
3677
1/2
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
692 if(start==0)
3678 {
3679 692 MsgStrings[0].s = "(None)";
3680 692 MsgStrings[0].listpos = 0;
3681 692 }
3682 692 }
3683
3684 693 int32_t readstrings(PACKFILE *f, zquestheader *Header)
3685 {
3686
2/2
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 24 times.
693 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_strings);
3687
3688 693 MsgStr tempMsgString;
3689
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 init_msgstr(&tempMsgString);
3690
3691 693 word temp_msg_count=0;
3692 word temp_expansion[16];
3693 693 memset(temp_expansion, 0, 16*sizeof(word));
3694 693 char buf[8193] = {0};
3695
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 669 times.
693 if(Header->zelda_version < 0x193)
3696 {
3697 byte tempbyte;
3698 24 int32_t strings_to_read=0;
3699
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3700
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3701
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
3702
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3703 {
3704 18 strings_to_read=128;
3705 18 temp_msg_count=Header->old_str_count;
3706
3707 // Some sort of string count corruption seems to be common in old quests
3708
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(temp_msg_count>128)
3709 {
3710 temp_msg_count=128;
3711 }
3712 18 }
3713
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3714 {
3715 strings_to_read=255;
3716 temp_msg_count=Header->old_str_count;
3717 }
3718 else
3719 {
3720
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_igetw(&temp_msg_count,f))
3721 {
3722 return qe_invalid;
3723 }
3724
3725 6 strings_to_read=temp_msg_count;
3726
3727
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
6 if (!should_skip && temp_msg_count >= msg_strings_size)
3728 {
3729 Z_message("Reallocating string buffer...\n");
3730
3731 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3732 // return qe_nomem;
3733
3734 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3735 delete[] MsgStrings;
3736 MsgStrings = new MsgStr[MAXMSGS];
3737 msg_strings_size = MAXMSGS;
3738 for(auto q = 0; q < msg_strings_size; ++q)
3739 {
3740 MsgStrings[q].clear();
3741 }
3742 }
3743 }
3744
3745 //reset the message strings
3746
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3747
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 init_msgstrings(0,msg_strings_size);
3748
3749
2/2
✓ Branch 0 taken 2550 times.
✓ Branch 1 taken 24 times.
2574 for(int32_t x=0; x<strings_to_read; x++)
3750 {
3751
1/2
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
2550 init_msgstr(&tempMsgString);
3752 2550 tempMsgString.listpos = x;
3753
3754
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!pfread(buf,73,f))
3755 {
3756 return qe_invalid;
3757 }
3758
3759 2550 buf[74] = '\0';
3760
1/2
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
2550 tempMsgString.s = buf;
3761
3762
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!p_getc(&tempbyte,f))
3763 {
3764 return qe_invalid;
3765 }
3766
3767
3/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 2304 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 246 times.
2796 if((Header->zelda_version < 0x192)||
3768
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3769 {
3770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2304 times.
2304 tempMsgString.nextstring=tempbyte?x+1:0;
3771
3772
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3773 {
3774 return qe_invalid;
3775 }
3776
3777
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3778 {
3779 return qe_invalid;
3780 }
3781 2304 }
3782 else
3783 {
3784
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!p_igetw(&tempMsgString.nextstring,f))
3785 {
3786 return qe_invalid;
3787 }
3788
3789
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!pfread(temp_expansion,32,f))
3790 {
3791 return qe_invalid;
3792 }
3793 }
3794
3795
2/2
✓ Branch 0 taken 2549 times.
✓ Branch 1 taken 1 times.
2550 if (!should_skip)
3796
1/2
✓ Branch 0 taken 2549 times.
✗ Branch 1 not taken.
2549 MsgStrings[x] = tempMsgString;
3797 2550 }
3798 24 }
3799 else
3800 {
3801 int32_t dummy_int;
3802 word s_version;
3803 word s_cversion;
3804
3805 //section version info
3806
2/4
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 669 times.
✗ Branch 3 not taken.
669 if(!p_igetw(&s_version,f))
3807 {
3808 return qe_invalid;
3809 }
3810
3811 669 FFCore.quest_format[vStrings] = s_version;
3812
3813
2/4
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 669 times.
✗ Branch 3 not taken.
669 if(!p_igetw(&s_cversion,f))
3814 {
3815 return qe_invalid;
3816 }
3817
3818 //section size
3819
2/4
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 669 times.
✗ Branch 3 not taken.
669 if(!p_igetl(&dummy_int,f))
3820 {
3821 return qe_invalid;
3822 }
3823
3824 //finally... section data
3825
2/4
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 669 times.
✗ Branch 3 not taken.
669 if(!p_igetw(&temp_msg_count,f))
3826 {
3827 return qe_invalid;
3828 }
3829
3830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
669 if(temp_msg_count >= msg_strings_size)
3831 {
3832 Z_message("Reallocating string buffer...\n");
3833
3834 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3835 // return qe_nomem;
3836 delete[] MsgStrings;
3837 MsgStrings = new MsgStr[MAXMSGS];
3838 msg_strings_size = MAXMSGS;
3839 for(auto q = 0; q < msg_strings_size; ++q)
3840 {
3841 MsgStrings[q].clear();
3842 }
3843 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3844 }
3845
3846 //reset the message strings
3847
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 421 times.
669 if(s_version < 7)
3848
1/2
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
248 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3849
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 init_msgstrings(0,msg_strings_size);
3850
3851 669 int32_t string_length=(s_version<2)?73:145;
3852
3853
2/2
✓ Branch 0 taken 133876 times.
✓ Branch 1 taken 669 times.
134545 for(int32_t i=0; i<temp_msg_count; i++)
3854 {
3855
1/2
✓ Branch 0 taken 133876 times.
✗ Branch 1 not taken.
133876 init_msgstr(&tempMsgString);
3856 133876 tempMsgString.listpos = i;
3857
2/2
✓ Branch 0 taken 5682 times.
✓ Branch 1 taken 128194 times.
133876 if(s_version > 8)
3858 {
3859
2/4
✓ Branch 0 taken 5682 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5682 times.
✗ Branch 3 not taken.
5682 if(!p_igetl(&string_length,f))
3860 {
3861 return qe_invalid;
3862 }
3863 5682 }
3864
3865
2/4
✓ Branch 0 taken 133876 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 133876 times.
133876 if (string_length < 0 || string_length > 8193)
3866 {
3867 return qe_invalid;
3868 }
3869
3870
2/2
✓ Branch 0 taken 133354 times.
✓ Branch 1 taken 522 times.
133876 if (string_length > 0)
3871 {
3872
2/4
✓ Branch 0 taken 133354 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133354 times.
✗ Branch 3 not taken.
133354 if (!pfread(buf, string_length, f))
3873 {
3874 return qe_invalid;
3875 }
3876 133354 }
3877 else
3878 {
3879 522 buf[0] = 0;
3880 }
3881
3882
2/4
✓ Branch 0 taken 133876 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133876 times.
✗ Branch 3 not taken.
133876 if(!p_igetw(&tempMsgString.nextstring,f))
3883 {
3884 return qe_invalid;
3885 }
3886
3887
2/2
✓ Branch 0 taken 33613 times.
✓ Branch 1 taken 100263 times.
133876 if(s_version<2)
3888 {
3889 33613 buf[72] = '\0';
3890
1/2
✓ Branch 0 taken 33613 times.
✗ Branch 1 not taken.
33613 tempMsgString.s = buf;
3891 33613 }
3892 else
3893 {
3894 // June 2008: A bug corrupted the last 4 chars of a string.
3895 // Discard these.
3896
1/2
✓ Branch 0 taken 100263 times.
✗ Branch 1 not taken.
100263 if(s_version<3)
3897 {
3898 for(int32_t j=140; j<144; j++)
3899 {
3900 buf[j] = '\0';
3901 }
3902 }
3903
1/2
✓ Branch 0 taken 100263 times.
✗ Branch 1 not taken.
100263 if(string_length > 8192) string_length = 8192;
3904 100263 buf[string_length]='\0'; //Force-terminate
3905
1/2
✓ Branch 0 taken 100263 times.
✗ Branch 1 not taken.
100263 tempMsgString.s = buf;
3906
3907
2/2
✓ Branch 0 taken 5682 times.
✓ Branch 1 taken 94581 times.
100263 if ( s_version >= 6 )
3908 {
3909
2/4
✓ Branch 0 taken 5682 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5682 times.
✗ Branch 3 not taken.
5682 if(!p_igetl(&tempMsgString.tile,f))
3910 {
3911 return qe_invalid;
3912 }
3913 5682 }
3914 else
3915 {
3916
2/4
✓ Branch 0 taken 94581 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94581 times.
✗ Branch 3 not taken.
94581 if(!p_igetw(&tempMsgString.tile,f))
3917 {
3918 return qe_invalid;
3919 }
3920 }
3921
3922
2/4
✓ Branch 0 taken 100263 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100263 times.
✗ Branch 3 not taken.
100263 if(!p_getc(&tempMsgString.cset,f))
3923 {
3924 return qe_invalid;
3925 }
3926
3927 byte dummy_char;
3928
3929
2/4
✓ Branch 0 taken 100263 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100263 times.
✗ Branch 3 not taken.
100263 if(!p_getc(&dummy_char,f)) // trans is stored as a char...
3930 {
3931 return qe_invalid;
3932 }
3933
3934 100263 tempMsgString.trans=dummy_char!=0;
3935
3936
2/4
✓ Branch 0 taken 100263 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100263 times.
✗ Branch 3 not taken.
100263 if(!p_getc(&tempMsgString.font,f))
3937 {
3938 return qe_invalid;
3939 }
3940
3941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100263 times.
100263 if(s_version < 5)
3942 {
3943 if(!p_getc(&tempMsgString.y,f))
3944 {
3945 return qe_invalid;
3946 }
3947 }
3948 else
3949 {
3950
2/4
✓ Branch 0 taken 100263 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100263 times.
✗ Branch 3 not taken.
100263 if(!p_igetw(&tempMsgString.x,f))
3951 {
3952 return qe_invalid;
3953 }
3954
3955
2/4
✓ Branch 0 taken 100263 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100263 times.
✗ Branch 3 not taken.
100263 if(!p_igetw(&tempMsgString.y,f))
3956 {
3957 return qe_invalid;
3958 }
3959
3960
2/4
✓ Branch 0 taken 100263 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100263 times.
✗ Branch 3 not taken.
100263 if(!p_igetw(&tempMsgString.w,f))
3961 {
3962 return qe_invalid;
3963 }
3964
3965
2/4
✓ Branch 0 taken 100263 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100263 times.
✗ Branch 3 not taken.
100263 if(!p_igetw(&tempMsgString.h,f))
3966 {
3967 return qe_invalid;
3968 }
3969
3970
2/4
✓ Branch 0 taken 100263 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100263 times.
✗ Branch 3 not taken.
100263 if(!p_getc(&tempMsgString.hspace,f))
3971 {
3972 return qe_invalid;
3973 }
3974
3975
2/4
✓ Branch 0 taken 100263 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100263 times.
✗ Branch 3 not taken.
100263 if(!p_getc(&tempMsgString.vspace,f))
3976 {
3977 return qe_invalid;
3978 }
3979
3980
2/4
✓ Branch 0 taken 100263 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100263 times.
✗ Branch 3 not taken.
100263 if(!p_getc(&tempMsgString.stringflags,f))
3981 {
3982 return qe_invalid;
3983 }
3984 }
3985
3986
2/2
✓ Branch 0 taken 94581 times.
✓ Branch 1 taken 5682 times.
100263 if(s_version >= 7)
3987 {
3988
2/2
✓ Branch 0 taken 5682 times.
✓ Branch 1 taken 22728 times.
28410 for(int32_t q = 0; q < 4; ++q)
3989 {
3990
2/4
✓ Branch 0 taken 22728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22728 times.
✗ Branch 3 not taken.
22728 if(!p_getc(&tempMsgString.margins[q],f))
3991 {
3992 return qe_invalid;
3993 }
3994 22728 }
3995
3996
2/4
✓ Branch 0 taken 5682 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5682 times.
✗ Branch 3 not taken.
5682 if(!p_igetl(&tempMsgString.portrait_tile,f))
3997 {
3998 return qe_invalid;
3999 }
4000
4001
2/4
✓ Branch 0 taken 5682 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5682 times.
✗ Branch 3 not taken.
5682 if(!p_getc(&tempMsgString.portrait_cset,f))
4002 {
4003 return qe_invalid;
4004 }
4005
4006
2/4
✓ Branch 0 taken 5682 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5682 times.
✗ Branch 3 not taken.
5682 if(!p_getc(&tempMsgString.portrait_x,f))
4007 {
4008 return qe_invalid;
4009 }
4010
4011
2/4
✓ Branch 0 taken 5682 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5682 times.
✗ Branch 3 not taken.
5682 if(!p_getc(&tempMsgString.portrait_y,f))
4012 {
4013 return qe_invalid;
4014 }
4015
4016
2/4
✓ Branch 0 taken 5682 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5682 times.
✗ Branch 3 not taken.
5682 if(!p_getc(&tempMsgString.portrait_tw,f))
4017 {
4018 return qe_invalid;
4019 }
4020
4021
2/4
✓ Branch 0 taken 5682 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5682 times.
✗ Branch 3 not taken.
5682 if(!p_getc(&tempMsgString.portrait_th,f))
4022 {
4023 return qe_invalid;
4024 }
4025 5682 }
4026
4027
2/2
✓ Branch 0 taken 5682 times.
✓ Branch 1 taken 94581 times.
100263 if(s_version >= 8)
4028 {
4029
2/4
✓ Branch 0 taken 5682 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5682 times.
✗ Branch 3 not taken.
5682 if(!p_getc(&tempMsgString.shadow_type,f))
4030 {
4031 return qe_invalid;
4032 }
4033
4034
2/4
✓ Branch 0 taken 5682 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5682 times.
✗ Branch 3 not taken.
5682 if(!p_getc(&tempMsgString.shadow_color,f))
4035 {
4036 return qe_invalid;
4037 }
4038 5682 }
4039
4040
2/2
✓ Branch 0 taken 5373 times.
✓ Branch 1 taken 94890 times.
100263 if(s_version >= 10)
4041 {
4042
2/4
✓ Branch 0 taken 5373 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5373 times.
✗ Branch 3 not taken.
5373 if(!p_getc(&tempMsgString.drawlayer,f))
4043 {
4044 return qe_invalid;
4045 }
4046 5373 }
4047
4048
2/4
✓ Branch 0 taken 100263 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100263 times.
✗ Branch 3 not taken.
100263 if(!p_getc(&tempMsgString.sfx,f))
4049 {
4050 return qe_invalid;
4051 }
4052
4053
1/2
✓ Branch 0 taken 100263 times.
✗ Branch 1 not taken.
100263 if(s_version>3)
4054 {
4055
2/4
✓ Branch 0 taken 100263 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100263 times.
✗ Branch 3 not taken.
100263 if(!p_igetw(&tempMsgString.listpos,f))
4056 {
4057 return qe_invalid;
4058 }
4059 100263 }
4060 }
4061
4062
1/2
✓ Branch 0 taken 133876 times.
✗ Branch 1 not taken.
133876 MsgStrings[i].copyAll(tempMsgString);
4063 133876 }
4064 }
4065
4066
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 692 times.
693 if (!should_skip)
4067 692 msg_count=temp_msg_count;
4068
4069 693 return 0;
4070 693 }
4071
4072 693 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header)
4073 {
4074
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 669 times.
693 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_doors);
4075
4076
3/4
✓ Branch 0 taken 675 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
699 if((Header->zelda_version < 0x192)||
4077
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 669 times.
675 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4078 {
4079 18 return 0;
4080 }
4081
4082 675 word temp_door_combo_set_count=0;
4083 DoorComboSet tempDoorComboSet;
4084 word dummy_word;
4085 int32_t dummy_long;
4086 byte padding;
4087 675 int32_t s_version = 0;
4088
4089
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 674 times.
675 if (!should_skip)
4090
2/2
✓ Branch 0 taken 172544 times.
✓ Branch 1 taken 674 times.
173218 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4091 {
4092 172544 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4093 173218 }
4094
4095
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 669 times.
675 if(Header->zelda_version > 0x192)
4096 {
4097 //section version info
4098
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&s_version,f))
4099 {
4100 return qe_invalid;
4101 }
4102
4103 669 FFCore.quest_format[vDoors] = s_version;
4104
4105
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&dummy_word,f))
4106 {
4107 return qe_invalid;
4108 }
4109
4110 //section size
4111
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetl(&dummy_long,f))
4112 {
4113 return qe_invalid;
4114 }
4115 669 }
4116
4117 //finally... section data
4118
1/2
✓ Branch 0 taken 675 times.
✗ Branch 1 not taken.
675 if(!p_igetw(&temp_door_combo_set_count,f))
4119 {
4120 return qe_invalid;
4121 }
4122
4123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 675 times.
675 if (temp_door_combo_set_count > MAXDOORCOMBOSETS)
4124 {
4125 return qe_invalid;
4126 }
4127
4128
2/2
✓ Branch 0 taken 5643 times.
✓ Branch 1 taken 675 times.
6318 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4129 {
4130 5643 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4131
4132 //name
4133
1/2
✓ Branch 0 taken 5643 times.
✗ Branch 1 not taken.
5643 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f))
4134 {
4135 return qe_invalid;
4136 }
4137
4138
2/2
✓ Branch 0 taken 5603 times.
✓ Branch 1 taken 40 times.
5643 if(Header->zelda_version < 0x193)
4139 {
4140
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&padding,f))
4141 {
4142 return qe_invalid;
4143 }
4144 40 }
4145
4146 //up door
4147
2/2
✓ Branch 0 taken 50787 times.
✓ Branch 1 taken 5643 times.
56430 for(int32_t j=0; j<9; j++)
4148 {
4149
2/2
✓ Branch 0 taken 203148 times.
✓ Branch 1 taken 50787 times.
253935 for(int32_t k=0; k<4; k++)
4150 {
4151
1/2
✓ Branch 0 taken 203148 times.
✗ Branch 1 not taken.
203148 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f))
4152 {
4153 return qe_invalid;
4154 }
4155 203148 }
4156 50787 }
4157
4158
2/2
✓ Branch 0 taken 50787 times.
✓ Branch 1 taken 5643 times.
56430 for(int32_t j=0; j<9; j++)
4159 {
4160
2/2
✓ Branch 0 taken 203148 times.
✓ Branch 1 taken 50787 times.
253935 for(int32_t k=0; k<4; k++)
4161 {
4162
1/2
✓ Branch 0 taken 203148 times.
✗ Branch 1 not taken.
203148 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f))
4163 {
4164 return qe_invalid;
4165 }
4166 203148 }
4167 50787 }
4168
4169 //down door
4170
2/2
✓ Branch 0 taken 50787 times.
✓ Branch 1 taken 5643 times.
56430 for(int32_t j=0; j<9; j++)
4171 {
4172
2/2
✓ Branch 0 taken 203148 times.
✓ Branch 1 taken 50787 times.
253935 for(int32_t k=0; k<4; k++)
4173 {
4174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203148 times.
203148 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f))
4175 {
4176 return qe_invalid;
4177 }
4178 203148 }
4179 50787 }
4180
4181
2/2
✓ Branch 0 taken 50787 times.
✓ Branch 1 taken 5643 times.
56430 for(int32_t j=0; j<9; j++)
4182 {
4183
2/2
✓ Branch 0 taken 203148 times.
✓ Branch 1 taken 50787 times.
253935 for(int32_t k=0; k<4; k++)
4184 {
4185
1/2
✓ Branch 0 taken 203148 times.
✗ Branch 1 not taken.
203148 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f))
4186 {
4187 return qe_invalid;
4188 }
4189 203148 }
4190 50787 }
4191
4192 //left door
4193
2/2
✓ Branch 0 taken 50787 times.
✓ Branch 1 taken 5643 times.
56430 for(int32_t j=0; j<9; j++)
4194 {
4195
2/2
✓ Branch 0 taken 304722 times.
✓ Branch 1 taken 50787 times.
355509 for(int32_t k=0; k<6; k++)
4196 {
4197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304722 times.
304722 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f))
4198 {
4199 return qe_invalid;
4200 }
4201 304722 }
4202 50787 }
4203
4204
2/2
✓ Branch 0 taken 50787 times.
✓ Branch 1 taken 5643 times.
56430 for(int32_t j=0; j<9; j++)
4205 {
4206
2/2
✓ Branch 0 taken 304722 times.
✓ Branch 1 taken 50787 times.
355509 for(int32_t k=0; k<6; k++)
4207 {
4208
1/2
✓ Branch 0 taken 304722 times.
✗ Branch 1 not taken.
304722 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f))
4209 {
4210 return qe_invalid;
4211 }
4212 304722 }
4213 50787 }
4214
4215 //right door
4216
2/2
✓ Branch 0 taken 50787 times.
✓ Branch 1 taken 5643 times.
56430 for(int32_t j=0; j<9; j++)
4217 {
4218
2/2
✓ Branch 0 taken 304722 times.
✓ Branch 1 taken 50787 times.
355509 for(int32_t k=0; k<6; k++)
4219 {
4220
1/2
✓ Branch 0 taken 304722 times.
✗ Branch 1 not taken.
304722 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f))
4221 {
4222 return qe_invalid;
4223 }
4224 304722 }
4225 50787 }
4226
4227
2/2
✓ Branch 0 taken 50787 times.
✓ Branch 1 taken 5643 times.
56430 for(int32_t j=0; j<9; j++)
4228 {
4229
2/2
✓ Branch 0 taken 304722 times.
✓ Branch 1 taken 50787 times.
355509 for(int32_t k=0; k<6; k++)
4230 {
4231
1/2
✓ Branch 0 taken 304722 times.
✗ Branch 1 not taken.
304722 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f))
4232 {
4233 return qe_invalid;
4234 }
4235 304722 }
4236 50787 }
4237
4238 //up bomb rubble
4239
2/2
✓ Branch 0 taken 11286 times.
✓ Branch 1 taken 5643 times.
16929 for(int32_t j=0; j<2; j++)
4240 {
4241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11286 times.
11286 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f))
4242 {
4243 return qe_invalid;
4244 }
4245 11286 }
4246
4247
2/2
✓ Branch 0 taken 11286 times.
✓ Branch 1 taken 5643 times.
16929 for(int32_t j=0; j<2; j++)
4248 {
4249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11286 times.
11286 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f))
4250 {
4251 return qe_invalid;
4252 }
4253 11286 }
4254
4255 //down bomb rubble
4256
2/2
✓ Branch 0 taken 11286 times.
✓ Branch 1 taken 5643 times.
16929 for(int32_t j=0; j<2; j++)
4257 {
4258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11286 times.
11286 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f))
4259 {
4260 return qe_invalid;
4261 }
4262 11286 }
4263
4264
2/2
✓ Branch 0 taken 11286 times.
✓ Branch 1 taken 5643 times.
16929 for(int32_t j=0; j<2; j++)
4265 {
4266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11286 times.
11286 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f))
4267 {
4268 return qe_invalid;
4269 }
4270 11286 }
4271
4272 //left bomb rubble
4273
2/2
✓ Branch 0 taken 16929 times.
✓ Branch 1 taken 5643 times.
22572 for(int32_t j=0; j<3; j++)
4274 {
4275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16929 times.
16929 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f))
4276 {
4277 return qe_invalid;
4278 }
4279 16929 }
4280
4281
2/2
✓ Branch 0 taken 16929 times.
✓ Branch 1 taken 5643 times.
22572 for(int32_t j=0; j<3; j++)
4282 {
4283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16929 times.
16929 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f))
4284 {
4285 return qe_invalid;
4286 }
4287 16929 }
4288
4289
2/2
✓ Branch 0 taken 5603 times.
✓ Branch 1 taken 40 times.
5643 if(Header->zelda_version < 0x193)
4290 {
4291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4292 {
4293 return qe_invalid;
4294 }
4295
4296 40 }
4297
4298 //right bomb rubble
4299
2/2
✓ Branch 0 taken 16929 times.
✓ Branch 1 taken 5643 times.
22572 for(int32_t j=0; j<3; j++)
4300 {
4301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16929 times.
16929 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f))
4302 {
4303 return qe_invalid;
4304 }
4305 16929 }
4306
4307
2/2
✓ Branch 0 taken 16929 times.
✓ Branch 1 taken 5643 times.
22572 for(int32_t j=0; j<3; j++)
4308 {
4309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16929 times.
16929 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f))
4310 {
4311 return qe_invalid;
4312 }
4313 16929 }
4314
4315
2/2
✓ Branch 0 taken 5603 times.
✓ Branch 1 taken 40 times.
5643 if(Header->zelda_version < 0x193)
4316 {
4317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4318 {
4319 return qe_invalid;
4320 }
4321 40 }
4322
4323 //walkthrough stuff
4324
2/2
✓ Branch 0 taken 22572 times.
✓ Branch 1 taken 5643 times.
28215 for(int32_t j=0; j<4; j++)
4325 {
4326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22572 times.
22572 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f))
4327 {
4328 return qe_invalid;
4329 }
4330 22572 }
4331
4332
2/2
✓ Branch 0 taken 22572 times.
✓ Branch 1 taken 5643 times.
28215 for(int32_t j=0; j<4; j++)
4333 {
4334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22572 times.
22572 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f))
4335 {
4336 return qe_invalid;
4337 }
4338 22572 }
4339
4340 //flags
4341
2/2
✓ Branch 0 taken 11286 times.
✓ Branch 1 taken 5643 times.
16929 for(int32_t j=0; j<2; j++)
4342 {
4343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11286 times.
11286 if(!p_getc(&tempDoorComboSet.flags[j],f))
4344 {
4345 return qe_invalid;
4346 }
4347 11286 }
4348
4349
2/2
✓ Branch 0 taken 5603 times.
✓ Branch 1 taken 40 times.
5643 if(Header->zelda_version < 0x193)
4350 {
4351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f))
4352 {
4353 return qe_invalid;
4354 }
4355 40 }
4356
4357
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5629 times.
5643 if (!should_skip)
4358 5629 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4359 5643 }
4360
4361
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 674 times.
675 if (!should_skip)
4362 674 door_combo_set_count=temp_door_combo_set_count;
4363
4364 675 return 0;
4365 693 }
4366
4367 6 int32_t count_dmaps()
4368 {
4369 6 int32_t i=MAXDMAPS-1;
4370 6 bool found=false;
4371
4372
4/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 6 times.
6 while(i>=0 && !found)
4373 {
4374
4/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
18 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4375
3/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
6 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4376
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4377 12 found=true;
4378
4379
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 12 times.
60 for(int32_t j=0; j<8; j++)
4380 {
4381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(DMaps[i].grid[j]!=0)
4382
4383 found=true;
4384 48 }
4385
4386
5/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 6 times.
12 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4387 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4388 18 found=true;
4389
4390
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
18 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4391
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4392
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4393
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4394 12 found=true;
4395
4396 if(!found)
4397 {
4398 i--;
4399 }
4400 }
4401
4402 6 return i+1;
4403 }
4404
4405
4406 6 int32_t count_shops(miscQdata *Misc)
4407 {
4408 6 int32_t i=NUM_SHOPS-1,j;
4409 6 bool found=false;
4410
4411
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1480 times.
✓ Branch 2 taken 1476 times.
✓ Branch 3 taken 6 times.
1482 while(i>=0 && !found)
4412 {
4413 1476 j=2;
4414
4415
4/4
✓ Branch 0 taken 1472 times.
✓ Branch 1 taken 4424 times.
✓ Branch 2 taken 4420 times.
✓ Branch 3 taken 1476 times.
5896 while(j>=0 && !found)
4416 {
4417
3/4
✓ Branch 0 taken 4416 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4416 times.
4420 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4418 {
4419 4 found=true;
4420 4 }
4421 else
4422 {
4423 4416 j--;
4424 }
4425 }
4426
4427
1/2
✓ Branch 0 taken 1476 times.
✗ Branch 1 not taken.
1476 if(Misc->shop[i].name[0]!=0)
4428 {
4429 found=true;
4430 }
4431
4432
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1472 times.
1476 if(!found)
4433 {
4434 1472 i--;
4435 1472 }
4436 }
4437
4438 6 return i+1;
4439 }
4440
4441 6 int32_t count_infos(miscQdata *Misc)
4442 {
4443 6 int32_t i=255,j;
4444 6 bool found=false;
4445
4446
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1480 times.
✓ Branch 2 taken 1476 times.
✓ Branch 3 taken 6 times.
1482 while(i>=0 && !found)
4447 {
4448 1476 j=2;
4449
4450
4/4
✓ Branch 0 taken 1472 times.
✓ Branch 1 taken 4424 times.
✓ Branch 2 taken 4420 times.
✓ Branch 3 taken 1476 times.
5896 while(j>=0 && !found)
4451 {
4452
4/4
✓ Branch 0 taken 4419 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 4416 times.
4420 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4453 {
4454 4 found=true;
4455 4 }
4456 else
4457 {
4458 4416 j--;
4459 }
4460 }
4461
4462
1/2
✓ Branch 0 taken 1476 times.
✗ Branch 1 not taken.
1476 if(Misc->info[i].name[0]!=0)
4463 {
4464 found=true;
4465 }
4466
4467
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1472 times.
1476 if(!found)
4468 {
4469 1472 i--;
4470 1472 }
4471 }
4472
4473 6 return i+1;
4474 }
4475
4476 6 int32_t count_warprings(miscQdata *Misc)
4477 {
4478 6 int32_t i=15,j;
4479 6 bool found=false;
4480
4481
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 6 times.
36 while(i>=0 && !found)
4482 {
4483 30 j=7;
4484
4485
4/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 222 times.
✓ Branch 2 taken 216 times.
✓ Branch 3 taken 30 times.
246 while(j>=0 && !found)
4486 {
4487
4/4
✓ Branch 0 taken 213 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 210 times.
216 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4488 {
4489 6 found=true;
4490 6 }
4491 else
4492 {
4493 210 j--;
4494 }
4495 }
4496
4497
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 24 times.
30 if(!found)
4498 {
4499 24 i--;
4500 24 }
4501 }
4502
4503 6 return i+1;
4504 }
4505
4506 6 int32_t count_palcycles(miscQdata *Misc)
4507 {
4508 6 int32_t i=255,j;
4509 6 bool found=false;
4510
4511
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1406 times.
✓ Branch 2 taken 1402 times.
✓ Branch 3 taken 6 times.
1408 while(i>=0 && !found)
4512 {
4513 1402 j=2;
4514
4515
4/4
✓ Branch 0 taken 1398 times.
✓ Branch 1 taken 4202 times.
✓ Branch 2 taken 4198 times.
✓ Branch 3 taken 1402 times.
5600 while(j>=0 && !found)
4516 {
4517
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4194 times.
4198 if(Misc->cycles[i][j].count!=0)
4518 {
4519 4 found=true;
4520 4 }
4521 else
4522 {
4523 4194 j--;
4524 }
4525 }
4526
4527
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1398 times.
1402 if(!found)
4528 {
4529 1398 i--;
4530 1398 }
4531 }
4532
4533 6 return i+1;
4534 }
4535
4536 1336221 void clear_screen(mapscr *temp_scr)
4537 {
4538 1336221 temp_scr->zero_memory();
4539 1336221 }
4540
4541 // NOTE: when modifying this, you need to also update:
4542 // readonedmap, readdmaps, and FFScript::read_dmaps
4543 // (and their associated write functions)
4544 3765 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps)
4545 {
4546
2/2
✓ Branch 0 taken 3741 times.
✓ Branch 1 taken 24 times.
3765 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_dmaps);
4547
4548 3765 word dmapstoread=0;
4549 3765 dmap tempDMap;
4550
4551 int32_t dummy;
4552 3765 word s_version=0, s_cversion=0;
4553 byte padding;
4554
4555 char legacy_title[22];
4556
4557
2/2
✓ Branch 0 taken 3073 times.
✓ Branch 1 taken 692 times.
3765 if (!should_skip)
4558
2/2
✓ Branch 0 taken 354304 times.
✓ Branch 1 taken 692 times.
354996 for(int32_t i=0; i<max_dmaps; i++)
4559 {
4560
1/2
✓ Branch 0 taken 354304 times.
✗ Branch 1 not taken.
354304 DMaps[start_dmap + i].clear();
4561 354304 sprintf(legacy_title," ");
4562 354304 sprintf(DMaps[start_dmap+i].intro," ");
4563 354304 DMaps[start_dmap+i].type |= dmCAVE;
4564 354996 }
4565
4566
4/4
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 669 times.
✓ Branch 3 taken 24 times.
3765 if(!Header || Header->zelda_version > 0x192)
4567 {
4568 //section version info
4569
3/4
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 669 times.
✗ Branch 3 not taken.
3741 if(!p_igetw(&s_version,f))
4570 {
4571 return qe_invalid;
4572 }
4573
4574 669 FFCore.quest_format[vDMaps] = s_version;
4575
4576
4577
2/4
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 669 times.
✗ Branch 3 not taken.
669 if(!p_igetw(&s_cversion,f))
4578 {
4579 return qe_invalid;
4580 }
4581
4582 //section size
4583
2/4
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 669 times.
✗ Branch 3 not taken.
669 if(!p_igetl(&dummy,f))
4584 {
4585 return qe_invalid;
4586 }
4587
4588 //finally... section data
4589
2/4
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 669 times.
✗ Branch 3 not taken.
669 if(!p_igetw(&dmapstoread,f))
4590 {
4591 return qe_invalid;
4592 }
4593 669 }
4594 else
4595 {
4596
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
4597
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4598 {
4599 18 dmapstoread=32;
4600 18 }
4601
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else if(s_version <= 4)
4602 {
4603 6 dmapstoread=OLDMAXDMAPS;
4604 6 }
4605 else
4606 {
4607 dmapstoread=MAXDMAPS;
4608 }
4609 }
4610
4611
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 610 times.
693 dmapstoread=zc_min(dmapstoread, max_dmaps);
4612
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 610 times.
693 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4613
4614
2/2
✓ Branch 0 taken 329536 times.
✓ Branch 1 taken 693 times.
330229 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4615 {
4616
1/2
✓ Branch 0 taken 329536 times.
✗ Branch 1 not taken.
329536 tempDMap.clear();
4617 329536 sprintf(legacy_title," ");
4618 329536 sprintf(tempDMap.intro," ");
4619
4620
2/4
✓ Branch 0 taken 329536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 329536 times.
✗ Branch 3 not taken.
329536 if(!p_getc(&tempDMap.map,f))
4621 {
4622 return qe_invalid;
4623 }
4624
4625
2/2
✓ Branch 0 taken 17216 times.
✓ Branch 1 taken 312320 times.
329536 if(s_version <= 4)
4626 {
4627 byte tempbyte;
4628
4629
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4630 {
4631 return qe_invalid;
4632 }
4633
4634 17216 tempDMap.level=(word)tempbyte;
4635 17216 }
4636 else
4637 {
4638
2/4
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312320 times.
✗ Branch 3 not taken.
312320 if(!p_igetw(&tempDMap.level,f))
4639 {
4640 return qe_invalid;
4641 }
4642 }
4643
4644
2/4
✓ Branch 0 taken 329536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 329536 times.
✗ Branch 3 not taken.
329536 if(!p_getc(&tempDMap.xoff,f))
4645 {
4646 return qe_invalid;
4647 }
4648
4649
2/4
✓ Branch 0 taken 329536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 329536 times.
✗ Branch 3 not taken.
329536 if(!p_getc(&tempDMap.compass,f))
4650 {
4651 return qe_invalid;
4652 }
4653
4654
2/2
✓ Branch 0 taken 312320 times.
✓ Branch 1 taken 17216 times.
329536 if(s_version > 8) // February 2009
4655 {
4656
2/4
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312320 times.
✗ Branch 3 not taken.
312320 if(!p_igetw(&tempDMap.color,f))
4657 {
4658 return qe_invalid;
4659 }
4660 312320 }
4661 else
4662 {
4663 byte tempbyte;
4664
4665
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4666 {
4667 return qe_invalid;
4668 }
4669
4670 17216 tempDMap.color = (word)tempbyte;
4671 }
4672
4673
2/4
✓ Branch 0 taken 329536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 329536 times.
✗ Branch 3 not taken.
329536 if(!p_getc(&tempDMap.midi,f))
4674 {
4675 return qe_invalid;
4676 }
4677
4678
2/4
✓ Branch 0 taken 329536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 329536 times.
✗ Branch 3 not taken.
329536 if(!p_getc(&tempDMap.cont,f))
4679 {
4680 return qe_invalid;
4681 }
4682
4683
2/4
✓ Branch 0 taken 329536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 329536 times.
✗ Branch 3 not taken.
329536 if(!p_getc(&tempDMap.type,f))
4684 {
4685 return qe_invalid;
4686 }
4687
4688
4/4
✓ Branch 0 taken 5484 times.
✓ Branch 1 taken 324052 times.
✓ Branch 2 taken 5440 times.
✓ Branch 3 taken 44 times.
335020 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4689
1/2
✓ Branch 0 taken 5484 times.
✗ Branch 1 not taken.
5484 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4690 5440 tempDMap.xoff = 0;
4691
4692
2/2
✓ Branch 0 taken 329536 times.
✓ Branch 1 taken 2636288 times.
2965824 for(int32_t j=0; j<8; j++)
4693 {
4694
2/4
✓ Branch 0 taken 2636288 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2636288 times.
✗ Branch 3 not taken.
2636288 if(!p_getc(&tempDMap.grid[j],f))
4695 {
4696 return qe_invalid;
4697 }
4698 2636288 }
4699
4700
5/6
✓ Branch 0 taken 329536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 328960 times.
✓ Branch 3 taken 576 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 327424 times.
329536 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4701 {
4702
4/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 1975 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 127 times.
2112 if(tempDMap.level>0&&tempDMap.level<10)
4703 {
4704 127 sprintf(legacy_title,"LEVEL-%d ", tempDMap.level);
4705 127 }
4706
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 1536 times.
2112 tempDMap.title.assign(legacy_title);
4707
4708
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 558 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
576 if(i==0 && Header->zelda_version <= 0x190)
4709 {
4710
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.cont = std::max((int)tempDMap.cont - tempDMap.xoff, 0);
4711
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.compass = std::max((int)tempDMap.compass - tempDMap.xoff, 0);
4712 18 }
4713
4714 //forgotten -DD
4715
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 439 times.
576 if(tempDMap.level==0)
4716 {
4717 439 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4718 439 }
4719 576 }
4720 else
4721 {
4722
3/4
✓ Branch 0 taken 328960 times.
✓ Branch 1 taken 1536 times.
✓ Branch 2 taken 328960 times.
✗ Branch 3 not taken.
327424 if(!p_getstr(tempDMap.name,sizeof(DMaps[0].name) - 1,f))
4723 {
4724 return qe_invalid;
4725 }
4726
4727
2/2
✓ Branch 0 taken 122624 times.
✓ Branch 1 taken 206336 times.
328960 if(s_version<20)
4728 {
4729
2/4
✓ Branch 0 taken 122624 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 122624 times.
✗ Branch 3 not taken.
122624 if (!p_getstr(legacy_title, sizeof(legacy_title) - 1, f))
4730 {
4731 return qe_invalid;
4732 }
4733
1/2
✓ Branch 0 taken 122624 times.
✗ Branch 1 not taken.
122624 tempDMap.title.assign(legacy_title);
4734 122624 }
4735 else
4736 {
4737
2/4
✓ Branch 0 taken 206336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 206336 times.
✗ Branch 3 not taken.
206336 if (!p_getwstr(&tempDMap.title, f))
4738 {
4739 return qe_invalid;
4740 }
4741 }
4742
4743
2/4
✓ Branch 0 taken 328960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 328960 times.
✗ Branch 3 not taken.
328960 if(!p_getstr(tempDMap.intro,sizeof(DMaps[0].intro)-1,f))
4744 {
4745 return qe_invalid;
4746 }
4747
4748
5/8
✓ Branch 0 taken 328960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 328960 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 327424 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1536 times.
328960 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4749 {
4750 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4751 DMaps[i] = tempDMap;
4752
4753 continue;
4754 }
4755
4756
3/4
✓ Branch 0 taken 328960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 327424 times.
328960 if(Header && (Header->zelda_version < 0x193))
4757 {
4758
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4759 {
4760 return qe_invalid;
4761 }
4762 1536 }
4763
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 113408 times.
328960 if ( s_version >= 11 )
4764 {
4765
2/4
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215552 times.
✗ Branch 3 not taken.
215552 if(!p_igetl(&tempDMap.minimap_1_tile,f))
4766 {
4767 return qe_invalid;
4768 }
4769 215552 }
4770 else
4771 {
4772
2/4
✓ Branch 0 taken 113408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113408 times.
✗ Branch 3 not taken.
113408 if(!p_igetw(&tempDMap.minimap_1_tile,f))
4773 {
4774 return qe_invalid;
4775 }
4776 }
4777
4778
2/4
✓ Branch 0 taken 328960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 328960 times.
✗ Branch 3 not taken.
328960 if(!p_getc(&tempDMap.minimap_1_cset,f))
4779 {
4780 return qe_invalid;
4781 }
4782
4783
3/4
✓ Branch 0 taken 328960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 327424 times.
328960 if(Header && (Header->zelda_version < 0x193))
4784 {
4785
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4786 {
4787 return qe_invalid;
4788 }
4789 1536 }
4790
4791
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 113408 times.
328960 if ( s_version >= 11 )
4792 {
4793
2/4
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215552 times.
✗ Branch 3 not taken.
215552 if(!p_igetl(&tempDMap.minimap_2_tile,f))
4794 {
4795 return qe_invalid;
4796 }
4797 215552 }
4798 else
4799 {
4800
2/4
✓ Branch 0 taken 113408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113408 times.
✗ Branch 3 not taken.
113408 if(!p_igetw(&tempDMap.minimap_2_tile,f))
4801 {
4802 return qe_invalid;
4803 }
4804 }
4805
2/4
✓ Branch 0 taken 328960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 328960 times.
✗ Branch 3 not taken.
328960 if(!p_getc(&tempDMap.minimap_2_cset,f))
4806 {
4807 return qe_invalid;
4808 }
4809
4810
3/4
✓ Branch 0 taken 328960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 327424 times.
328960 if(Header && (Header->zelda_version < 0x193))
4811 {
4812
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4813 {
4814 return qe_invalid;
4815 }
4816 1536 }
4817
4818
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 113408 times.
328960 if ( s_version >= 11 )
4819 {
4820
2/4
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215552 times.
✗ Branch 3 not taken.
215552 if(!p_igetl(&tempDMap.largemap_1_tile,f))
4821 {
4822 return qe_invalid;
4823 }
4824 215552 }
4825 else
4826 {
4827
2/4
✓ Branch 0 taken 113408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113408 times.
✗ Branch 3 not taken.
113408 if(!p_igetw(&tempDMap.largemap_1_tile,f))
4828 {
4829 return qe_invalid;
4830 }
4831 }
4832
4833
2/4
✓ Branch 0 taken 328960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 328960 times.
✗ Branch 3 not taken.
328960 if(!p_getc(&tempDMap.largemap_1_cset,f))
4834 {
4835 return qe_invalid;
4836 }
4837
4838
3/4
✓ Branch 0 taken 328960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 327424 times.
328960 if(Header && (Header->zelda_version < 0x193))
4839 {
4840
4841
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4842 {
4843 return qe_invalid;
4844 }
4845 1536 }
4846
4847
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 113408 times.
328960 if ( s_version >= 11 )
4848 {
4849
2/4
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215552 times.
✗ Branch 3 not taken.
215552 if(!p_igetl(&tempDMap.largemap_2_tile,f))
4850 {
4851 return qe_invalid;
4852 }
4853 215552 }
4854 else
4855 {
4856
2/4
✓ Branch 0 taken 113408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113408 times.
✗ Branch 3 not taken.
113408 if(!p_igetw(&tempDMap.largemap_2_tile,f))
4857 {
4858 return qe_invalid;
4859 }
4860 }
4861
2/4
✓ Branch 0 taken 328960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 328960 times.
✗ Branch 3 not taken.
328960 if(!p_getc(&tempDMap.largemap_2_cset,f))
4862 {
4863 return qe_invalid;
4864 }
4865
4866
2/4
✓ Branch 0 taken 328960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 328960 times.
✗ Branch 3 not taken.
328960 if(!p_getstr(tempDMap.tmusic,sizeof(DMaps[0].tmusic)-1,f))
4867 {
4868 return qe_invalid;
4869 }
4870 }
4871
4872
2/2
✓ Branch 0 taken 312320 times.
✓ Branch 1 taken 17216 times.
329536 if(s_version>1)
4873 {
4874
2/4
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312320 times.
✗ Branch 3 not taken.
312320 if(!p_getc(&tempDMap.tmusictrack,f))
4875 {
4876 return qe_invalid;
4877 }
4878
4879
2/4
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312320 times.
✗ Branch 3 not taken.
312320 if(!p_getc(&tempDMap.active_subscreen,f))
4880 {
4881 return qe_invalid;
4882 }
4883
4884
2/4
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312320 times.
✗ Branch 3 not taken.
312320 if(!p_getc(&tempDMap.passive_subscreen,f))
4885 {
4886 return qe_invalid;
4887 }
4888 312320 }
4889
4890
2/2
✓ Branch 0 taken 312320 times.
✓ Branch 1 taken 17216 times.
329536 if(s_version>2)
4891 {
4892 byte di[32];
4893
4894
2/4
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312320 times.
✗ Branch 3 not taken.
312320 if(!pfread(&di, 32, f)) return qe_invalid;
4895
4896
2/2
✓ Branch 0 taken 79953920 times.
✓ Branch 1 taken 312320 times.
80266240 for(int32_t j=0; j<MAXITEMS; j++)
4897 {
4898
2/2
✓ Branch 0 taken 9038 times.
✓ Branch 1 taken 79944882 times.
79953920 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4899 79944882 else tempDMap.disableditems[j]=0;
4900 79953920 }
4901 312320 }
4902
4903
2/2
✓ Branch 0 taken 312320 times.
✓ Branch 1 taken 17216 times.
329536 if(s_version >= 6)
4904 {
4905
2/4
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312320 times.
✗ Branch 3 not taken.
312320 if(!p_igetl(&tempDMap.flags,f))
4906 {
4907 return qe_invalid;
4908 }
4909 312320 }
4910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17216 times.
17216 else if(s_version>3)
4911 {
4912 char temp;
4913
4914 if(!p_getc(&temp,f))
4915 {
4916 return qe_invalid;
4917 }
4918
4919 tempDMap.flags = temp;
4920 }
4921
3/8
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8992 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
17216 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4922 {
4923 8992 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4924 8992 }
4925 else
4926 8224 tempDMap.flags=0;
4927
4928
2/2
✓ Branch 0 taken 312320 times.
✓ Branch 1 taken 17216 times.
329536 if(s_version<7)
4929 {
4930
5/6
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8992 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2846 times.
✓ Branch 5 taken 6146 times.
17216 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4931 6146 tempDMap.flags|= dmfVIEWMAP;
4932 17216 }
4933
4934
2/2
✓ Branch 0 taken 312320 times.
✓ Branch 1 taken 17216 times.
329536 if(s_version<8)
4935 {
4936
4/4
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8050 times.
✓ Branch 3 taken 942 times.
17216 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4937 {
4938
1/2
✓ Branch 0 taken 8050 times.
✗ Branch 1 not taken.
8050 tempDMap.type &= ~dmDNGN;
4939 8050 tempDMap.type |= dmCAVE;
4940 8050 }
4941
2/2
✓ Branch 0 taken 6834 times.
✓ Branch 1 taken 2332 times.
9166 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4942 {
4943 2332 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4944 2332 }
4945 17216 }
4946
4947
7/8
✓ Branch 0 taken 329536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2112 times.
✓ Branch 3 taken 327424 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 576 times.
✓ Branch 6 taken 1536 times.
✓ Branch 7 taken 327424 times.
329536 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
4948 328960 && (Header->zelda_version < 0x193))
4949 {
4950
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4951 {
4952 return qe_invalid;
4953 }
4954 1536 }
4955
4956
2/2
✓ Branch 0 taken 113984 times.
✓ Branch 1 taken 215552 times.
329536 if(s_version >= 10)
4957 {
4958
2/4
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215552 times.
✗ Branch 3 not taken.
215552 if(!p_getc(&tempDMap.sideview,f))
4959 {
4960 return qe_invalid;
4961 }
4962 215552 }
4963
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 113984 times.
329536 if(s_version < 10) tempDMap.sideview = 0;
4964
4965 //Dmap Scripts
4966
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 113984 times.
329536 if(s_version >= 12)
4967 {
4968
2/4
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215552 times.
✗ Branch 3 not taken.
215552 if(!p_igetw(&tempDMap.script,f))
4969 {
4970 return qe_invalid;
4971 }
4972
2/2
✓ Branch 0 taken 1724416 times.
✓ Branch 1 taken 215552 times.
1939968 for ( int32_t q = 0; q < 8; q++ )
4973 {
4974
2/4
✓ Branch 0 taken 1724416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1724416 times.
✗ Branch 3 not taken.
1724416 if(!p_igetl(&tempDMap.initD[q],f))
4975 {
4976 return qe_invalid;
4977 }
4978 1724416 }
4979 215552 }
4980
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 113984 times.
329536 if ( s_version < 12 )
4981 {
4982 113984 tempDMap.script = 0;
4983
2/2
✓ Branch 0 taken 911872 times.
✓ Branch 1 taken 113984 times.
1025856 for ( int32_t q = 0; q < 8; q++ )
4984 {
4985 911872 tempDMap.initD[q] = 0;
4986 911872 }
4987 113984 }
4988
4989
2/2
✓ Branch 0 taken 113984 times.
✓ Branch 1 taken 215552 times.
329536 if(s_version >= 13)
4990 {
4991
2/2
✓ Branch 0 taken 1724416 times.
✓ Branch 1 taken 215552 times.
1939968 for ( int32_t q = 0; q < 8; q++ )
4992 {
4993
2/2
✓ Branch 0 taken 112087040 times.
✓ Branch 1 taken 1724416 times.
113811456 for ( int32_t w = 0; w < 65; w++ )
4994 {
4995
2/4
✓ Branch 0 taken 112087040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112087040 times.
✗ Branch 3 not taken.
112087040 if(!p_getc(&tempDMap.initD_label[q][w],f))
4996 {
4997 return qe_invalid;
4998 }
4999 112087040 }
5000 1724416 }
5001 215552 }
5002
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 113984 times.
329536 if ( s_version < 13 )
5003 {
5004 113984 tempDMap.script = 0;
5005
2/2
✓ Branch 0 taken 911872 times.
✓ Branch 1 taken 113984 times.
1025856 for ( int32_t q = 0; q < 8; q++ )
5006 {
5007
2/2
✓ Branch 0 taken 59271680 times.
✓ Branch 1 taken 911872 times.
60183552 for ( int32_t w = 0; w < 65; w++ )
5008 59271680 tempDMap.initD_label[q][w] = 0;
5009 911872 }
5010 113984 }
5011
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 113984 times.
329536 if(s_version >= 14)
5012 {
5013
2/4
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215552 times.
✗ Branch 3 not taken.
215552 if(!p_igetw(&tempDMap.active_sub_script,f))
5014 {
5015 return qe_invalid;
5016 }
5017
2/4
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215552 times.
✗ Branch 3 not taken.
215552 if(!p_igetw(&tempDMap.passive_sub_script,f))
5018 {
5019 return qe_invalid;
5020 }
5021
2/2
✓ Branch 0 taken 1724416 times.
✓ Branch 1 taken 215552 times.
1939968 for ( int32_t q = 0; q < 8; ++q )
5022 {
5023
2/4
✓ Branch 0 taken 1724416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1724416 times.
✗ Branch 3 not taken.
1724416 if(!p_igetl(&tempDMap.sub_initD[q],f))
5024 {
5025 return qe_invalid;
5026 }
5027 1724416 }
5028
2/2
✓ Branch 0 taken 1724416 times.
✓ Branch 1 taken 215552 times.
1939968 for(int32_t q = 0; q < 8; ++q)
5029 {
5030
2/2
✓ Branch 0 taken 112087040 times.
✓ Branch 1 taken 1724416 times.
113811456 for ( int32_t w = 0; w < 65; ++w )
5031 {
5032
2/4
✓ Branch 0 taken 112087040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112087040 times.
✗ Branch 3 not taken.
112087040 if(!p_getc(&tempDMap.sub_initD_label[q][w],f))
5033 {
5034 return qe_invalid;
5035 }
5036 112087040 }
5037 1724416 }
5038 215552 }
5039 else
5040 {
5041 113984 tempDMap.active_sub_script = 0;
5042 113984 tempDMap.passive_sub_script = 0;
5043
2/2
✓ Branch 0 taken 911872 times.
✓ Branch 1 taken 113984 times.
1025856 for(int32_t q = 0; q < 8; ++q)
5044 {
5045 911872 tempDMap.sub_initD[q] = 0;
5046
2/2
✓ Branch 0 taken 59271680 times.
✓ Branch 1 taken 911872 times.
60183552 for(int32_t w = 0; w < 65; ++w)
5047 59271680 tempDMap.sub_initD_label[q][w] = 0;
5048 911872 }
5049 }
5050
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 113984 times.
329536 if(s_version >= 15)
5051 {
5052
2/4
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215552 times.
✗ Branch 3 not taken.
215552 if(!p_igetw(&tempDMap.onmap_script,f))
5053 {
5054 return qe_invalid;
5055 }
5056
2/2
✓ Branch 0 taken 1724416 times.
✓ Branch 1 taken 215552 times.
1939968 for ( int32_t q = 0; q < 8; ++q )
5057 {
5058
2/4
✓ Branch 0 taken 1724416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1724416 times.
✗ Branch 3 not taken.
1724416 if(!p_igetl(&tempDMap.onmap_initD[q],f))
5059 {
5060 return qe_invalid;
5061 }
5062 1724416 }
5063
2/2
✓ Branch 0 taken 1724416 times.
✓ Branch 1 taken 215552 times.
1939968 for(int32_t q = 0; q < 8; ++q)
5064 {
5065
2/2
✓ Branch 0 taken 112087040 times.
✓ Branch 1 taken 1724416 times.
113811456 for ( int32_t w = 0; w < 65; ++w )
5066 {
5067
2/4
✓ Branch 0 taken 112087040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112087040 times.
✗ Branch 3 not taken.
112087040 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f))
5068 {
5069 return qe_invalid;
5070 }
5071 112087040 }
5072 1724416 }
5073 215552 }
5074 else
5075 {
5076 113984 tempDMap.onmap_script = 0;
5077
2/2
✓ Branch 0 taken 911872 times.
✓ Branch 1 taken 113984 times.
1025856 for(int32_t q = 0; q < 8; ++q)
5078 {
5079 911872 tempDMap.onmap_initD[q] = 0;
5080
2/2
✓ Branch 0 taken 59271680 times.
✓ Branch 1 taken 911872 times.
60183552 for(int32_t w = 0; w < 65; ++w)
5081 {
5082 59271680 tempDMap.onmap_initD_label[q][w] = 0;
5083 59271680 }
5084 911872 }
5085 }
5086
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 113984 times.
329536 if(s_version >= 16)
5087 {
5088
2/4
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215552 times.
✗ Branch 3 not taken.
215552 if(!p_igetw(&tempDMap.mirrorDMap,f))
5089 {
5090 return qe_invalid;
5091 }
5092 215552 }
5093 else
5094 {
5095 113984 tempDMap.mirrorDMap = -1;
5096 }
5097
5098
2/2
✓ Branch 0 taken 123200 times.
✓ Branch 1 taken 206336 times.
329536 if (s_version >= 17)
5099 {
5100 // Reserved for z3.
5101 206336 }
5102
5103 // Enhanced music loop points
5104
2/2
✓ Branch 0 taken 206336 times.
✓ Branch 1 taken 123200 times.
329536 if (s_version >= 18)
5105 {
5106
2/4
✓ Branch 0 taken 206336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 206336 times.
✗ Branch 3 not taken.
206336 if (!p_igetl(&tempDMap.tmusic_loop_start, f))
5107 {
5108 return qe_invalid;
5109 }
5110
2/4
✓ Branch 0 taken 206336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 206336 times.
✗ Branch 3 not taken.
206336 if (!p_igetl(&tempDMap.tmusic_loop_end, f))
5111 {
5112 return qe_invalid;
5113 }
5114
2/4
✓ Branch 0 taken 206336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 206336 times.
✗ Branch 3 not taken.
206336 if (!p_igetl(&tempDMap.tmusic_xfade_in, f))
5115 {
5116 return qe_invalid;
5117 }
5118
2/4
✓ Branch 0 taken 206336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 206336 times.
✗ Branch 3 not taken.
206336 if (!p_igetl(&tempDMap.tmusic_xfade_out, f))
5119 {
5120 return qe_invalid;
5121 }
5122 206336 }
5123 else
5124 {
5125 123200 tempDMap.tmusic_loop_start = 0;
5126 123200 tempDMap.tmusic_loop_end = 0;
5127 123200 tempDMap.tmusic_xfade_in = 0;
5128 123200 tempDMap.tmusic_xfade_out = 0;
5129 }
5130
5131
2/2
✓ Branch 0 taken 206336 times.
✓ Branch 1 taken 123200 times.
329536 if(s_version >= 19)
5132
2/4
✓ Branch 0 taken 206336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 206336 times.
✗ Branch 3 not taken.
206336 if(!p_getc(&tempDMap.overlay_subscreen, f))
5133 return qe_invalid;
5134
5135
2/2
✓ Branch 0 taken 206336 times.
✓ Branch 1 taken 123200 times.
329536 if (s_version >= 20)
5136 {
5137
2/4
✓ Branch 0 taken 206336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 206336 times.
✗ Branch 3 not taken.
206336 if (!p_igetl(&tempDMap.intro_string_id, f))
5138 return qe_invalid;
5139 206336 }
5140 else
5141 123200 tempDMap.intro_string_id = 0;
5142
5143 // Reserved for z3.
5144
2/2
✓ Branch 0 taken 123200 times.
✓ Branch 1 taken 206336 times.
329536 if(s_version >= 21)
5145 {
5146
2/2
✓ Branch 0 taken 1650688 times.
✓ Branch 1 taken 206336 times.
1857024 for(int32_t j=0; j<8; j++)
5147 {
5148
2/2
✓ Branch 0 taken 13205504 times.
✓ Branch 1 taken 1650688 times.
14856192 for(int32_t k=0; k<8; k++)
5149 {
5150 char c;
5151
2/4
✓ Branch 0 taken 13205504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13205504 times.
✗ Branch 3 not taken.
13205504 if(!p_getc(&c,f))
5152 {
5153 return qe_invalid;
5154 }
5155 13205504 }
5156 1650688 }
5157 206336 }
5158
5159
2/2
✓ Branch 0 taken 329280 times.
✓ Branch 1 taken 256 times.
329536 if (!should_skip)
5160 {
5161
1/2
✓ Branch 0 taken 329280 times.
✗ Branch 1 not taken.
329280 if(loading_tileset_flags & TILESET_CLEARMAPS)
5162 tempDMap.map = 0;
5163
1/2
✓ Branch 0 taken 329280 times.
✗ Branch 1 not taken.
329280 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
5164 {
5165 tempDMap.script = 0;
5166 for(int q = 0; q < 8; ++q)
5167 tempDMap.initD[q] = 0;
5168 }
5169
1/2
✓ Branch 0 taken 329280 times.
✗ Branch 1 not taken.
329280 DMaps[i] = tempDMap;
5170 329280 }
5171 329536 }
5172
5173 693 return 0;
5174 6837 }
5175
5176 610 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5177 {
5178 //these are here to bypass compiler warnings about unused arguments
5179 610 Header=Header;
5180
5181 miscQdata temp_misc;
5182 610 word s_version=0, s_cversion=0;
5183 610 int32_t tempsize=0;
5184 word dummyw;
5185
5186 610 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5187
5188 //section version info
5189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if(!p_igetw(&s_version,f))
5190 {
5191 return qe_invalid;
5192 }
5193
5194 610 FFCore.quest_format[vColours] = s_version;
5195
5196 610 al_trace("Misc Colours section version: %d\n", s_version);
5197
5198
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_igetw(&s_cversion,f))
5199 {
5200 return qe_invalid;
5201 }
5202
5203
5204 //section size
5205
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_igetl(&tempsize,f))
5206 {
5207 return qe_invalid;
5208 }
5209
5210 //finally... section data
5211 610 readsize=0;
5212
5213
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_getc(&temp_misc.colors.text,f))
5214 {
5215 return qe_invalid;
5216 }
5217
5218
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_getc(&temp_misc.colors.caption,f))
5219 {
5220 return qe_invalid;
5221 }
5222
5223
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_getc(&temp_misc.colors.overw_bg,f))
5224 {
5225 return qe_invalid;
5226 }
5227
5228
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5229 {
5230 return qe_invalid;
5231 }
5232
5233
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5234 {
5235 return qe_invalid;
5236 }
5237
5238
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_getc(&temp_misc.colors.cave_fg,f))
5239 {
5240 return qe_invalid;
5241 }
5242
5243
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_getc(&temp_misc.colors.bs_dk,f))
5244 {
5245 return qe_invalid;
5246 }
5247
5248
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_getc(&temp_misc.colors.bs_goal,f))
5249 {
5250 return qe_invalid;
5251 }
5252
5253
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_getc(&temp_misc.colors.compass_lt,f))
5254 {
5255 return qe_invalid;
5256 }
5257
5258
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_getc(&temp_misc.colors.compass_dk,f))
5259 {
5260 return qe_invalid;
5261 }
5262
5263
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5264 {
5265 return qe_invalid;
5266 }
5267
5268
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_getc(&temp_misc.colors.triframe_color,f))
5269 {
5270 return qe_invalid;
5271 }
5272
5273
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_getc(&temp_misc.colors.hero_dot,f))
5274 {
5275 return qe_invalid;
5276 }
5277
5278
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5279 {
5280 return qe_invalid;
5281 }
5282
5283
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5284 {
5285 return qe_invalid;
5286 }
5287
5288
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5289 {
5290 return qe_invalid;
5291 }
5292
5293
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5294 {
5295 return qe_invalid;
5296 }
5297
5298
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5299 {
5300 return qe_invalid;
5301 }
5302
5303
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5304 {
5305 return qe_invalid;
5306 }
5307
5308
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5309 {
5310 return qe_invalid;
5311 }
5312
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 189 times.
610 if(s_version < 4)
5313 {
5314
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(!p_igetw(&dummyw,f))
5315 return qe_invalid;
5316 189 temp_misc.colors.triforce_tile = dummyw;
5317
5318
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(!p_igetw(&dummyw,f))
5319 return qe_invalid;
5320 189 temp_misc.colors.triframe_tile = dummyw;
5321
5322
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(!p_igetw(&dummyw,f))
5323 return qe_invalid;
5324 189 temp_misc.colors.overworld_map_tile = dummyw;
5325
5326
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(!p_igetw(&dummyw,f))
5327 return qe_invalid;
5328 189 temp_misc.colors.dungeon_map_tile = dummyw;
5329
5330
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(!p_igetw(&dummyw,f))
5331 return qe_invalid;
5332 189 temp_misc.colors.blueframe_tile = dummyw;
5333
5334
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(!p_igetw(&dummyw,f))
5335 return qe_invalid;
5336 189 temp_misc.colors.HCpieces_tile = dummyw;
5337 189 }
5338
5339
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5340 {
5341 return qe_invalid;
5342 }
5343
5344
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5345 {
5346 return qe_invalid;
5347 }
5348
5349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if(s_version < 2)
5350 {
5351 temp_misc.colors.msgtext = 0x01;
5352 }
5353 else
5354 {
5355
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_getc(&temp_misc.colors.msgtext, f))
5356 {
5357 return qe_invalid;
5358 }
5359 }
5360
5361
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 421 times.
610 if ( s_version >= 3 ) //expanded tile pages to 825
5362 {
5363
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_igetl(&temp_misc.colors.triforce_tile,f))
5364 {
5365 return qe_invalid;
5366 }
5367
5368
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_igetl(&temp_misc.colors.triframe_tile,f))
5369 {
5370 return qe_invalid;
5371 }
5372
5373
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f))
5374 {
5375 return qe_invalid;
5376 }
5377
5378
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f))
5379 {
5380 return qe_invalid;
5381 }
5382
5383
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_igetl(&temp_misc.colors.blueframe_tile,f))
5384 {
5385 return qe_invalid;
5386 }
5387
5388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
421 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f))
5389 {
5390 return qe_invalid;
5391 }
5392 421 }
5393
5394 610 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5395
5396 610 return 0;
5397 610 }
5398
5399 610 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc)
5400 {
5401 miscQdata temp_misc;
5402 610 word s_version=0, s_cversion=0;
5403 byte icons;
5404 610 int32_t tempsize=0;
5405
5406 610 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5407
5408 //section version info
5409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if(!p_igetw(&s_version,f))
5410 {
5411 return qe_invalid;
5412 }
5413
5414 610 FFCore.quest_format[vIcons] = s_version;
5415
5416
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_igetw(&s_cversion,f))
5417 {
5418 return qe_invalid;
5419 }
5420
5421
5422 //section size
5423
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_igetl(&tempsize,f))
5424 {
5425 return qe_invalid;
5426 }
5427
5428 //finally... section data
5429 610 readsize=0;
5430
5431 610 icons=4;
5432
5433
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 189 times.
610 if ( s_version >= 10 )
5434 {
5435
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t i=0; i<icons; i++)
5436 {
5437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_igetl(&temp_misc.icons[i],f))
5438 {
5439 return qe_invalid;
5440 }
5441 1684 }
5442 421 }
5443 else
5444 {
5445
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 189 times.
945 for(int32_t i=0; i<icons; i++)
5446 {
5447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 756 times.
756 if(!p_igetw(&temp_misc.icons[i],f))
5448 {
5449 return qe_invalid;
5450 }
5451 756 }
5452 }
5453
5454 610 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5455
5456 610 return 0;
5457 610 }
5458
5459 693 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5460 {
5461
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 669 times.
693 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_misc);
5462
5463 693 word maxinfos=256;
5464 693 word maxshops=256;
5465 693 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5466 693 word ponds=16, pondsize=72, expansionsize=98*2;
5467 byte tempbyte, padding;
5468 miscQdata temp_misc;
5469 693 word s_version=0, s_cversion=0;
5470 word swaptmp;
5471 693 int32_t tempsize=0;
5472
5473 693 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5474
5475
2/2
✓ Branch 0 taken 177408 times.
✓ Branch 1 taken 693 times.
178101 for(int32_t i=0; i<maxshops; ++i)
5476 {
5477 177408 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5478 177408 }
5479
5480
2/2
✓ Branch 0 taken 177408 times.
✓ Branch 1 taken 693 times.
178101 for(int32_t i=0; i<maxinfos; ++i)
5481 {
5482 177408 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5483 177408 }
5484
5485
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 669 times.
693 if(Header->zelda_version > 0x192)
5486 {
5487 //section version info
5488
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&s_version,f))
5489 {
5490 return qe_invalid;
5491 }
5492
5493 669 FFCore.quest_format[vMisc] = s_version;
5494
5495
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&s_cversion,f))
5496 {
5497 return qe_invalid;
5498 }
5499
5500
5501 //section size
5502
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetl(&tempsize,f))
5503 {
5504 return qe_invalid;
5505 }
5506 669 }
5507
5508 //finally... section data
5509 693 readsize=0;
5510
5511 //shops
5512
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 669 times.
693 if(Header->zelda_version > 0x192)
5513 {
5514
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&shops,f))
5515 {
5516 return qe_invalid;
5517 }
5518 669 }
5519
5520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
693 if (shops > NUM_SHOPS)
5521 {
5522 return qe_invalid;
5523 }
5524
5525
2/2
✓ Branch 0 taken 9939 times.
✓ Branch 1 taken 693 times.
10632 for(int32_t i=0; i<shops; i++)
5526 {
5527
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 8739 times.
9939 if(s_version > 6)
5528 {
5529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8739 times.
8739 if(!p_getstr(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name)-1,f))
5530 {
5531 return qe_invalid;
5532 }
5533 8739 }
5534
5535
2/2
✓ Branch 0 taken 29817 times.
✓ Branch 1 taken 9939 times.
39756 for(int32_t j=0; j<3; j++)
5536 {
5537
1/2
✓ Branch 0 taken 29817 times.
✗ Branch 1 not taken.
29817 if(!p_getc(&temp_misc.shop[i].item[j],f))
5538 {
5539 return qe_invalid;
5540 }
5541
5542
2/2
✓ Branch 0 taken 26217 times.
✓ Branch 1 taken 3600 times.
29817 if(s_version < 4)
5543 {
5544 3600 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5545 3600 }
5546 29817 }
5547
5548
2/2
✓ Branch 0 taken 9555 times.
✓ Branch 1 taken 384 times.
9939 if(Header->zelda_version < 0x193)
5549 {
5550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_getc(&tempbyte,f))
5551 {
5552 return qe_invalid;
5553 }
5554 384 }
5555
5556
2/2
✓ Branch 0 taken 29817 times.
✓ Branch 1 taken 9939 times.
39756 for(int32_t j=0; j<3; j++)
5557 {
5558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29817 times.
29817 if(!p_igetw(&temp_misc.shop[i].price[j],f))
5559 {
5560 return qe_invalid;
5561 }
5562 29817 }
5563
5564
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 8739 times.
9939 if(s_version > 3)
5565 {
5566
2/2
✓ Branch 0 taken 26217 times.
✓ Branch 1 taken 8739 times.
34956 for(int32_t j=0; j<3; j++)
5567 {
5568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26217 times.
26217 if(!p_getc(&temp_misc.shop[i].hasitem[j],f))
5569 return qe_invalid;
5570 26217 }
5571 8739 }
5572
5573 /*
5574 if(s_version < 8)
5575 {
5576 for(int32_t j=0; j<3; j++)
5577 {
5578 (&temp_misc.shop[i].str[j])=0; //initialise.
5579 }
5580 }
5581 */
5582 9939 }
5583
5584 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5585
2/2
✓ Branch 0 taken 177408 times.
✓ Branch 1 taken 693 times.
178101 for(int32_t i=0; i<maxshops; ++i)
5586 {
5587
2/2
✓ Branch 0 taken 354816 times.
✓ Branch 1 taken 177408 times.
532224 for(int32_t j=0; j<3-1; j++)
5588 {
5589
2/2
✓ Branch 0 taken 532224 times.
✓ Branch 1 taken 354816 times.
887040 for(int32_t k=0; k<2-j; k++)
5590 {
5591
2/2
✓ Branch 0 taken 14925 times.
✓ Branch 1 taken 517299 times.
532224 if(temp_misc.shop[i].hasitem[k]==0)
5592 {
5593 517299 swaptmp = temp_misc.shop[i].item[k];
5594 517299 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5595 517299 temp_misc.shop[i].item[k+1] = swaptmp;
5596 517299 swaptmp = temp_misc.shop[i].price[k];
5597 517299 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5598 517299 temp_misc.shop[i].price[k+1] = swaptmp;
5599 517299 swaptmp = temp_misc.shop[i].hasitem[k];
5600 517299 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5601 517299 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5602 517299 }
5603 532224 }
5604 354816 }
5605 177408 }
5606
5607 //infos
5608
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 669 times.
693 if(Header->zelda_version > 0x192)
5609 {
5610
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&infos,f))
5611 {
5612 return qe_invalid;
5613 }
5614 669 }
5615
5616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
693 if (infos > NUM_INFOS)
5617 {
5618 return qe_invalid;
5619 }
5620
5621
5622
2/2
✓ Branch 0 taken 9269 times.
✓ Branch 1 taken 693 times.
9962 for(int32_t i=0; i<infos; i++)
5623 {
5624
2/2
✓ Branch 0 taken 761 times.
✓ Branch 1 taken 8508 times.
9269 if(s_version > 6)
5625 {
5626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8508 times.
8508 if(!p_getstr(temp_misc.info[i].name,sizeof(temp_misc.info[i].name)-1,f))
5627 {
5628 return qe_invalid;
5629 }
5630 8508 }
5631
5632
2/2
✓ Branch 0 taken 27807 times.
✓ Branch 1 taken 9269 times.
37076 for(int32_t j=0; j<3; j++)
5633 {
5634
3/4
✓ Branch 0 taken 26943 times.
✓ Branch 1 taken 864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 288 times.
28095 if((Header->zelda_version < 0x192)||
5635
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 26655 times.
26943 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5636 {
5637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 864 times.
864 if(!p_getc(&tempbyte,f))
5638 {
5639 return qe_invalid;
5640 }
5641
5642 864 temp_misc.info[i].str[j]=tempbyte;
5643 864 }
5644 else
5645 {
5646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26943 times.
26943 if(!p_igetw(&temp_misc.info[i].str[j],f))
5647 {
5648 return qe_invalid;
5649 }
5650 }
5651 27807 }
5652
5653
2/2
✓ Branch 0 taken 8885 times.
✓ Branch 1 taken 384 times.
9269 if(Header->zelda_version < 0x193)
5654 {
5655
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&tempbyte,f))
5656 {
5657 return qe_invalid;
5658 }
5659 384 }
5660
5661
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 9173 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
9269 if((Header->zelda_version == 0x192)&&(Header->build>145))
5662 {
5663
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&padding,f))
5664 {
5665 return qe_invalid;
5666 }
5667 96 }
5668
5669
2/2
✓ Branch 0 taken 27807 times.
✓ Branch 1 taken 9269 times.
37076 for(int32_t j=0; j<3; j++)
5670 {
5671
1/2
✓ Branch 0 taken 27807 times.
✗ Branch 1 not taken.
27807 if(!p_igetw(&temp_misc.info[i].price[j],f))
5672 {
5673 return qe_invalid;
5674 }
5675 27807 }
5676 9269 }
5677
5678 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5679
2/2
✓ Branch 0 taken 177408 times.
✓ Branch 1 taken 693 times.
178101 for(int32_t i=0; i<maxinfos; ++i)
5680 {
5681
2/2
✓ Branch 0 taken 354816 times.
✓ Branch 1 taken 177408 times.
532224 for(int32_t j=0; j<3-1; j++)
5682 {
5683
2/2
✓ Branch 0 taken 532224 times.
✓ Branch 1 taken 354816 times.
887040 for(int32_t k=0; k<2-j; k++)
5684 {
5685
2/2
✓ Branch 0 taken 10501 times.
✓ Branch 1 taken 521723 times.
532224 if(temp_misc.info[i].str[k]==0)
5686 {
5687 521723 swaptmp = temp_misc.info[i].str[k];
5688 521723 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5689 521723 temp_misc.info[i].str[k+1] = swaptmp;
5690 521723 swaptmp = temp_misc.info[i].price[k];
5691 521723 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5692 521723 temp_misc.info[i].price[k+1] = swaptmp;
5693 521723 }
5694 532224 }
5695 354816 }
5696 177408 }
5697
5698
5699 //warp rings
5700
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 610 times.
693 if(s_version > 5)
5701 610 warprings++;
5702
5703
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 669 times.
693 if(Header->zelda_version > 0x192)
5704 {
5705
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&warprings,f))
5706 {
5707 return qe_invalid;
5708 }
5709
5710
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 104 times.
669 if (warprings > NUM_WARP_RINGS)
5711 {
5712 // return qe_invalid;
5713 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5714 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5715 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5716 104 }
5717 669 }
5718
5719
2/2
✓ Branch 0 taken 6754 times.
✓ Branch 1 taken 693 times.
7447 for(int32_t i=0; i<warprings; i++)
5720 {
5721 // See above comment on the `warprings` range check.
5722 6754 bool keepdata = i < NUM_WARP_RINGS;
5723
5724
2/2
✓ Branch 0 taken 59666 times.
✓ Branch 1 taken 6754 times.
66420 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5725 {
5726
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 50706 times.
59666 if(s_version <= 3)
5727 {
5728
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_getc(&tempbyte,f))
5729 {
5730 return qe_invalid;
5731 }
5732
5733
2/2
✓ Branch 0 taken 3192 times.
✓ Branch 1 taken 5768 times.
8960 if (keepdata)
5734 5768 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5735 8960 }
5736 else
5737 {
5738 word tempword;
5739
1/2
✓ Branch 0 taken 50706 times.
✗ Branch 1 not taken.
50706 if(!p_igetw(&tempword,f))
5740 {
5741 return qe_invalid;
5742 }
5743
5744
2/2
✓ Branch 0 taken 1296 times.
✓ Branch 1 taken 49410 times.
50706 if (keepdata)
5745 49410 temp_misc.warp[i].dmap[j] = tempword;
5746 }
5747 59666 }
5748
5749
2/2
✓ Branch 0 taken 59666 times.
✓ Branch 1 taken 6754 times.
66420 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5750 {
5751
1/2
✓ Branch 0 taken 59666 times.
✗ Branch 1 not taken.
59666 if(!p_getc(&tempbyte,f))
5752 {
5753 return qe_invalid;
5754 }
5755
2/2
✓ Branch 0 taken 4488 times.
✓ Branch 1 taken 55178 times.
59666 if (keepdata)
5756 55178 temp_misc.warp[i].scr[j] = tempbyte;
5757 59666 }
5758
5759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6754 times.
6754 if(!p_getc(&tempbyte,f))
5760 {
5761 return qe_invalid;
5762 }
5763
2/2
✓ Branch 0 taken 543 times.
✓ Branch 1 taken 6211 times.
6754 if (keepdata)
5764 6211 temp_misc.warp[i].size = tempbyte;
5765
5766
2/2
✓ Branch 0 taken 6562 times.
✓ Branch 1 taken 192 times.
6754 if(Header->zelda_version < 0x193)
5767 {
5768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f))
5769 {
5770 return qe_invalid;
5771 }
5772 192 }
5773 6754 }
5774
5775 //palette cycles
5776
2/2
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 24 times.
693 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5777 {
5778
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 24 times.
6168 for(int32_t i=0; i<256; i++)
5779 {
5780
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 6144 times.
24576 for(int32_t j=0; j<3; j++)
5781 {
5782 18432 temp_misc.cycles[i][j].first=0;
5783 18432 temp_misc.cycles[i][j].count=0;
5784 18432 temp_misc.cycles[i][j].speed=0;
5785 18432 }
5786 6144 }
5787
5788
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
5789
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5790 {
5791 18 palcycles=16;
5792 18 }
5793
5794
2/2
✓ Branch 0 taken 1824 times.
✓ Branch 1 taken 24 times.
1848 for(int32_t i=0; i<palcycles; i++)
5795 {
5796
2/2
✓ Branch 0 taken 5472 times.
✓ Branch 1 taken 1824 times.
7296 for(int32_t j=0; j<3; j++)
5797 {
5798
1/2
✓ Branch 0 taken 5472 times.
✗ Branch 1 not taken.
5472 if(!p_getc(&temp_misc.cycles[i][j].first,f))
5799 {
5800 return qe_invalid;
5801 }
5802
5803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].count,f))
5804 {
5805 return qe_invalid;
5806 }
5807
5808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
5809 {
5810 return qe_invalid;
5811 }
5812 5472 }
5813 1824 }
5814 24 }
5815
5816 //Wind warps are now just another warp ring.
5817
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 83 times.
693 if(s_version <= 5)
5818 {
5819
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 59 times.
83 if(Header->zelda_version > 0x192)
5820 {
5821
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_igetw(&windwarps,f))
5822 {
5823 return qe_invalid;
5824 }
5825 59 }
5826
5827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if (windwarps > NUM_WARP_RINGS)
5828 {
5829 return qe_invalid;
5830 }
5831
5832
2/2
✓ Branch 0 taken 665 times.
✓ Branch 1 taken 83 times.
748 for(int32_t i=0; i<windwarps; i++)
5833 {
5834
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version <= 3)
5835 {
5836
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(!p_getc(&tempbyte,f))
5837 {
5838 return qe_invalid;
5839 }
5840
5841 665 temp_misc.warp[8].dmap[i]=tempbyte;
5842 665 }
5843 else
5844 {
5845 if(!p_igetw(&temp_misc.warp[8].dmap[i],f))
5846 {
5847 return qe_invalid;
5848 }
5849 }
5850
5851
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(!p_getc(&temp_misc.warp[8].scr[i],f))
5852 {
5853 return qe_invalid;
5854 }
5855
5856 665 temp_misc.warp[8].size = 9;
5857
5858
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version == 5)
5859 {
5860 if(!p_getc(&tempbyte,f))
5861 {
5862 return qe_invalid;
5863 }
5864 }
5865 665 }
5866 83 }
5867
5868
5869 //triforce pieces
5870
2/2
✓ Branch 0 taken 5544 times.
✓ Branch 1 taken 693 times.
6237 for(int32_t i=0; i<triforces; i++)
5871 {
5872
1/2
✓ Branch 0 taken 5544 times.
✗ Branch 1 not taken.
5544 if(!p_getc(&temp_misc.triforce[i],f))
5873 {
5874 return qe_invalid;
5875 }
5876 5544 }
5877
5878 //misc color data
5879
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 83 times.
693 if(s_version<3)
5880 {
5881
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.text,f))
5882 {
5883 return qe_invalid;
5884 }
5885
5886
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.caption,f))
5887 {
5888 return qe_invalid;
5889 }
5890
5891
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.overw_bg,f))
5892 {
5893 return qe_invalid;
5894 }
5895
5896
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5897 {
5898 return qe_invalid;
5899 }
5900
5901
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5902 {
5903 return qe_invalid;
5904 }
5905
5906
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.cave_fg,f))
5907 {
5908 return qe_invalid;
5909 }
5910
5911
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bs_dk,f))
5912 {
5913 return qe_invalid;
5914 }
5915
5916
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bs_goal,f))
5917 {
5918 return qe_invalid;
5919 }
5920
5921
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.compass_lt,f))
5922 {
5923 return qe_invalid;
5924 }
5925
5926
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.compass_dk,f))
5927 {
5928 return qe_invalid;
5929 }
5930
5931
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5932 {
5933 return qe_invalid;
5934 }
5935
5936
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_color,f))
5937 {
5938 return qe_invalid;
5939 }
5940
5941
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.hero_dot,f))
5942 {
5943 return qe_invalid;
5944 }
5945
5946
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5947 {
5948 return qe_invalid;
5949 }
5950
5951
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5952 {
5953 return qe_invalid;
5954 }
5955
5956
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5957 {
5958 return qe_invalid;
5959 }
5960
5961
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5962 {
5963 return qe_invalid;
5964 }
5965
5966
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5967 {
5968 return qe_invalid;
5969 }
5970
5971
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5972 {
5973 return qe_invalid;
5974 }
5975
5976
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5977 {
5978 return qe_invalid;
5979 }
5980
5981
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.triforce_tile,f))
5982 {
5983 return qe_invalid;
5984 }
5985
5986
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.triframe_tile,f))
5987 {
5988 return qe_invalid;
5989 }
5990
5991
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f))
5992 {
5993 return qe_invalid;
5994 }
5995
5996
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f))
5997 {
5998 return qe_invalid;
5999 }
6000
6001
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.blueframe_tile,f))
6002 {
6003 return qe_invalid;
6004 }
6005
6006
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f))
6007 {
6008 return qe_invalid;
6009 }
6010
6011
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
6012 {
6013 return qe_invalid;
6014 }
6015
6016 83 temp_misc.colors.msgtext = 0x01;
6017
6018
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 24 times.
83 if(Header->zelda_version < 0x193)
6019 {
6020
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 24 times.
192 for(int32_t i=0; i<7; i++)
6021 {
6022
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if(!p_getc(&tempbyte,f))
6023 {
6024 return qe_invalid;
6025 }
6026 168 }
6027 24 }
6028
6029
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
83 if((Header->zelda_version == 0x192)&&(Header->build>145))
6030 {
6031
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<256; i++)
6032 {
6033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if(!p_getc(&tempbyte,f))
6034 {
6035 return qe_invalid;
6036 }
6037 1536 }
6038 6 }
6039
6040
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(s_version>1)
6041 {
6042 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
6043 {
6044 return qe_invalid;
6045 }
6046 }
6047
6048 //save game icons
6049
3/4
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
89 if((Header->zelda_version < 0x192)||
6050
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 59 times.
65 ((Header->zelda_version == 0x192)&&(Header->build<73)))
6051 {
6052 18 icons=3;
6053 18 }
6054
6055
2/2
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 83 times.
397 for(int32_t i=0; i<icons; i++)
6056 {
6057
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if(!p_igetw(&temp_misc.icons[i],f))
6058 {
6059 return qe_invalid;
6060 }
6061 314 }
6062 83 }
6063
6064
3/4
✓ Branch 0 taken 675 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
699 if((Header->zelda_version < 0x192)||
6065
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 669 times.
675 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6066 {
6067 18 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6068
6069 18 return 0;
6070 }
6071
6072 //pond information
6073
2/2
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 6 times.
675 if(Header->zelda_version < 0x193)
6074 {
6075
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<146))
6076 {
6077 pondsize=25;
6078 }
6079
6080
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 6 times.
102 for(int32_t i=0; i<ponds; i++)
6081 {
6082
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 96 times.
7008 for(int32_t j=0; j<pondsize; j++)
6083 {
6084
1/2
✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
6912 if(!p_getc(&tempbyte,f))
6085 {
6086 return qe_invalid;
6087
6088 }
6089 6912 }
6090 96 }
6091 6 }
6092
6093 //end string
6094
2/4
✓ Branch 0 taken 675 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
681 if((Header->zelda_version < 0x192)||
6095
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 669 times.
675 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6096 {
6097 if(!p_getc(&tempbyte,f))
6098 {
6099 return qe_invalid;
6100 }
6101
6102 temp_misc.endstring=tempbyte;
6103
6104 if(!p_getc(&tempbyte,f))
6105 {
6106 return qe_invalid;
6107 }
6108 }
6109 else
6110 {
6111
1/2
✓ Branch 0 taken 675 times.
✗ Branch 1 not taken.
675 if(!p_igetw(&temp_misc.endstring,f))
6112 {
6113 return qe_invalid;
6114 }
6115 }
6116
6117 //expansion
6118
2/2
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 6 times.
675 if(Header->zelda_version < 0x193)
6119 {
6120
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<73))
6121 {
6122 expansionsize=99*2;
6123 }
6124
6125
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 6 times.
1182 for(int32_t i=0; i<expansionsize; i++)
6126 {
6127
1/2
✓ Branch 0 taken 1176 times.
✗ Branch 1 not taken.
1176 if(!p_getc(&tempbyte,f))
6128 {
6129 return qe_invalid;
6130 }
6131 1176 }
6132 6 }
6133 //shops v8
6134
6135
6136
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 421 times.
675 if(s_version >= 8)
6137 {
6138
2/2
✓ Branch 0 taken 6560 times.
✓ Branch 1 taken 421 times.
6981 for(int32_t i=0; i<shops; i++)
6139 {
6140
2/2
✓ Branch 0 taken 19680 times.
✓ Branch 1 taken 6560 times.
26240 for(int32_t j=0; j<3; j++)
6141 {
6142
1/2
✓ Branch 0 taken 19680 times.
✗ Branch 1 not taken.
19680 if(!p_igetw(&temp_misc.shop[i].str[j],f))
6143 return qe_invalid;
6144 19680 }
6145 6560 }
6146 421 }
6147
6148 675 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6149 675 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6150 675 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6151
6152 //v9 includes quest misc[32]
6153
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 421 times.
675 if(s_version >= 9)
6154 {
6155
2/2
✓ Branch 0 taken 13472 times.
✓ Branch 1 taken 421 times.
13893 for ( int32_t q = 0; q < 32; q++ )
6156 {
6157
1/2
✓ Branch 0 taken 13472 times.
✗ Branch 1 not taken.
13472 if(!p_igetl(&temp_misc.questmisc[q],f))
6158 return qe_invalid;
6159 13472 }
6160
2/2
✓ Branch 0 taken 13472 times.
✓ Branch 1 taken 421 times.
13893 for ( int32_t q = 0; q < 32; q++ )
6161 {
6162
2/2
✓ Branch 0 taken 1724416 times.
✓ Branch 1 taken 13472 times.
1737888 for ( int32_t j = 0; j < 128; j++ )
6163
1/2
✓ Branch 0 taken 1724416 times.
✗ Branch 1 not taken.
1724416 if(!p_getc(&temp_misc.questmisc_strings[q][j],f))
6164 return qe_invalid;
6165 13472 }
6166 421 }
6167
6168
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 254 times.
675 if(s_version >= 11 )
6169 {
6170
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f))
6171 return qe_invalid;
6172 421 }
6173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 254 times.
254 else if(s_version < 11 )
6174 {
6175 254 temp_misc.zscript_last_compiled_version = -1;
6176 254 }
6177
6178 675 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6179
6180
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 254 times.
675 if(s_version >= 12)
6181 {
6182 byte spr;
6183
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 421 times.
108197 for(int32_t q = 0; q < sprMAX; ++q)
6184 {
6185
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if(!p_getc(&spr,f))
6186 return qe_invalid;
6187 107776 temp_misc.sprites[q] = spr;
6188 107776 }
6189 421 }
6190 else
6191 {
6192 254 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6193 //temp_misc.sprites[sprFALL] = ;
6194 }
6195
6196
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 254 times.
675 if(s_version >= 13)
6197 {
6198
2/2
✓ Branch 0 taken 26944 times.
✓ Branch 1 taken 421 times.
27365 for(size_t q = 0; q < 64; ++q)
6199 {
6200 26944 bottletype* bt = &(temp_misc.bottle_types[q]);
6201
1/2
✓ Branch 0 taken 26944 times.
✗ Branch 1 not taken.
26944 if (!p_getstr(bt->name, sizeof(bt->name)-1, f))
6202 return qe_invalid;
6203
2/2
✓ Branch 0 taken 80832 times.
✓ Branch 1 taken 26944 times.
107776 for(size_t j = 0; j < 3; ++j)
6204 {
6205
1/2
✓ Branch 0 taken 80832 times.
✗ Branch 1 not taken.
80832 if (!p_getc(&(bt->counter[j]), f))
6206 return qe_invalid;
6207
1/2
✓ Branch 0 taken 80832 times.
✗ Branch 1 not taken.
80832 if (!p_igetw(&(bt->amount[j]), f))
6208 return qe_invalid;
6209 80832 }
6210
1/2
✓ Branch 0 taken 26944 times.
✗ Branch 1 not taken.
26944 if (!p_getc(&(bt->flags), f))
6211 return qe_invalid;
6212
1/2
✓ Branch 0 taken 26944 times.
✗ Branch 1 not taken.
26944 if (!p_getc(&(bt->next_type), f))
6213 return qe_invalid;
6214 26944 }
6215
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 421 times.
108197 for(size_t q = 0; q < 256; ++q)
6216 {
6217 107776 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6218
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if (!pfread(bst->name, sizeof(bst->name)-1, f))
6219 return qe_invalid;
6220
2/2
✓ Branch 0 taken 323328 times.
✓ Branch 1 taken 107776 times.
431104 for(size_t j = 0; j < 3; ++j)
6221 {
6222
1/2
✓ Branch 0 taken 323328 times.
✗ Branch 1 not taken.
323328 if (!p_getc(&(bst->fill[j]), f))
6223 return qe_invalid;
6224
1/2
✓ Branch 0 taken 323328 times.
✗ Branch 1 not taken.
323328 if (!p_igetw(&(bst->comb[j]), f))
6225 return qe_invalid;
6226
1/2
✓ Branch 0 taken 323328 times.
✗ Branch 1 not taken.
323328 if (!p_getc(&(bst->cset[j]), f))
6227 return qe_invalid;
6228
1/2
✓ Branch 0 taken 323328 times.
✗ Branch 1 not taken.
323328 if (!p_igetw(&(bst->price[j]), f))
6229 return qe_invalid;
6230
1/2
✓ Branch 0 taken 323328 times.
✗ Branch 1 not taken.
323328 if (!p_igetw(&(bst->str[j]), f))
6231 return qe_invalid;
6232 323328 }
6233 107776 }
6234 421 }
6235 else
6236 {
6237
2/2
✓ Branch 0 taken 16256 times.
✓ Branch 1 taken 254 times.
16510 for(size_t q = 0; q < 64; ++q)
6238 16256 temp_misc.bottle_types[q].clear();
6239
2/2
✓ Branch 0 taken 65024 times.
✓ Branch 1 taken 254 times.
65278 for(size_t q = 0; q < 256; ++q)
6240 65024 temp_misc.bottle_shop_types[q].clear();
6241 }
6242
6243
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 254 times.
675 if(s_version >= 14)
6244 {
6245 byte msfx;
6246
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 421 times.
108197 for(int32_t q = 0; q < sfxMAX; ++q)
6247 {
6248
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if(!p_getc(&msfx,f))
6249 return qe_invalid;
6250 107776 temp_misc.miscsfx[q] = msfx;
6251 107776 }
6252 421 }
6253 else
6254 {
6255 254 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6256 254 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6257 254 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6258 }
6259
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 254 times.
675 if(s_version < 15)
6260 {
6261 254 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6262 254 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6263 254 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6264 254 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6265 254 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6266 254 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6267 254 }
6268
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 272 times.
675 if(s_version < 16)
6269 {
6270 272 temp_misc.miscsfx[sfxTAP] = WAV_ZN1TAP;
6271 272 temp_misc.miscsfx[sfxTAP_HOLLOW] = WAV_ZN1TAP2;
6272 272 }
6273
6274
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 674 times.
675 if (!should_skip)
6275 674 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6276
6277 675 return 0;
6278 693 }
6279
6280 extern char *item_string[MAXITEMS];
6281 extern const char *old_item_string[iLast];
6282 extern char *weapon_string[MAXWPNS];
6283 extern const char *old_weapon_string[wLast];
6284
6285 693 int32_t readitems(PACKFILE *f, word version, word build)
6286 {
6287
2/2
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 24 times.
693 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_items);
6288
6289 byte padding;
6290 int32_t dummy;
6291 693 word items_to_read=MAXITEMS;
6292 itemdata tempitem;
6293 693 word s_version=0, s_cversion=0;
6294 word dummy_word;
6295
6296
2/2
✓ Branch 0 taken 687 times.
✓ Branch 1 taken 6 times.
693 if(version < 0x186)
6297 {
6298 6 items_to_read=64;
6299 6 }
6300
6301
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 669 times.
693 if(version > 0x192)
6302 {
6303 669 items_to_read=0;
6304
6305 //section version info
6306
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&s_version,f))
6307 {
6308 return qe_invalid;
6309 }
6310
6311 669 FFCore.quest_format[vItems] = s_version;
6312
6313
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&s_cversion,f))
6314 {
6315 return qe_invalid;
6316 }
6317
6318 //section size
6319
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetl(&dummy,f))
6320 {
6321 return qe_invalid;
6322 }
6323
6324 //finally... section data
6325
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&items_to_read,f))
6326 {
6327 return qe_invalid;
6328 }
6329
6330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
669 if (items_to_read > MAXITEMS)
6331 {
6332 return qe_invalid;
6333 }
6334 669 }
6335
6336
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 83 times.
693 if(s_version>1)
6337 {
6338
2/2
✓ Branch 0 taken 156160 times.
✓ Branch 1 taken 610 times.
156770 for(int32_t i=0; i<items_to_read; i++)
6339 {
6340 char tempname[64];
6341
6342
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if(!pfread(tempname, 64, f))
6343 {
6344 return qe_invalid;
6345 }
6346
6347 156160 item_string[i][0] = '\0';
6348 156160 strncat(item_string[i], tempname, 64 - 1);
6349 156160 }
6350 610 }
6351
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
6352 {
6353
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
6354 {
6355 20992 reset_itemname(i);
6356 20992 }
6357 82 }
6358
6359
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 692 times.
693 if (!should_skip)
6360
2/2
✓ Branch 0 taken 177152 times.
✓ Branch 1 taken 692 times.
177844 for(int32_t i=0; i<MAXITEMS; i++)
6361 {
6362 177152 itemdata& id = itemsbuf[i];
6363 177152 memset(&id, 0, sizeof(itemdata));
6364 177152 id.count=-1;
6365 177152 id.playsound=WAV_SCALE;
6366 177152 reset_itembuf(&id,i);
6367 177844 }
6368
6369
2/2
✓ Branch 0 taken 165282 times.
✓ Branch 1 taken 693 times.
165975 for(int32_t i=0; i<items_to_read; i++)
6370 {
6371 165282 memset(&tempitem, 0, sizeof(itemdata));
6372 165282 reset_itembuf(&tempitem,i);
6373
6374
6375
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 57506 times.
165282 if ( s_version > 35 ) //expanded tiles
6376 {
6377
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if(!p_igetl(&tempitem.tile,f))
6378 {
6379 return qe_invalid;
6380 }
6381 107776 }
6382 else
6383 {
6384
1/2
✓ Branch 0 taken 57506 times.
✗ Branch 1 not taken.
57506 if(!p_igetw(&tempitem.tile,f))
6385 {
6386 return qe_invalid;
6387 }
6388 }
6389
6390
1/2
✓ Branch 0 taken 165282 times.
✗ Branch 1 not taken.
165282 if(!p_getc(&tempitem.misc_flags,f))
6391 {
6392 return qe_invalid;
6393 }
6394
6395
1/2
✓ Branch 0 taken 165282 times.
✗ Branch 1 not taken.
165282 if(!p_getc(&tempitem.csets,f))
6396 {
6397 return qe_invalid;
6398 }
6399
6400
1/2
✓ Branch 0 taken 165282 times.
✗ Branch 1 not taken.
165282 if(!p_getc(&tempitem.frames,f))
6401 {
6402 return qe_invalid;
6403 }
6404
6405
1/2
✓ Branch 0 taken 165282 times.
✗ Branch 1 not taken.
165282 if(!p_getc(&tempitem.speed,f))
6406 {
6407 return qe_invalid;
6408 }
6409
6410
1/2
✓ Branch 0 taken 165282 times.
✗ Branch 1 not taken.
165282 if(!p_getc(&tempitem.delay,f))
6411 {
6412 return qe_invalid;
6413 }
6414
6415
2/2
✓ Branch 0 taken 160290 times.
✓ Branch 1 taken 4992 times.
165282 if(version < 0x193)
6416 {
6417
1/2
✓ Branch 0 taken 4992 times.
✗ Branch 1 not taken.
4992 if(!p_getc(&padding,f))
6418 {
6419 return qe_invalid;
6420 }
6421
6422
4/6
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 3456 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✗ Branch 5 not taken.
4992 if((version < 0x192)||((version == 0x192)&&(build<186)))
6423 {
6424
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 4736 times.
4992 if (should_skip)
6425 256 continue;
6426
6427
3/3
✓ Branch 0 taken 4690 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
4736 switch(i)
6428 {
6429 case iShield:
6430 23 tempitem.ltm=get_qr(qr_BSZELDA)?-12:10;
6431 23 break;
6432
6433 case iMShield:
6434 23 tempitem.ltm=get_qr(qr_BSZELDA)?-6:-10;
6435 23 break;
6436
6437 default:
6438 4690 tempitem.ltm=0;
6439 4690 break;
6440 }
6441
6442 4736 tempitem.count=-1;
6443 4736 tempitem.flags=item_none;
6444 4736 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6445 4736 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6446 4736 tempitem.family=0xFF;
6447 4736 tempitem.playsound=WAV_SCALE;
6448 4736 reset_itembuf(&tempitem,i);
6449
6450 4736 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6451
6452 4736 continue;
6453 }
6454 }
6455
6456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160290 times.
160290 if(!p_igetl(&tempitem.ltm,f))
6457 {
6458 return qe_invalid;
6459 }
6460
6461
1/2
✓ Branch 0 taken 160290 times.
✗ Branch 1 not taken.
160290 if(version < 0x193)
6462 {
6463 for(int32_t q=0; q<12; q++)
6464 {
6465 if(!p_getc(&padding,f))
6466 {
6467 return qe_invalid;
6468 }
6469 }
6470 }
6471
6472
2/2
✓ Branch 0 taken 156160 times.
✓ Branch 1 taken 4130 times.
160290 if(s_version>1)
6473 {
6474
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 48384 times.
156160 if ( s_version >= 31 )
6475 {
6476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107776 times.
107776 if(!p_igetl(&tempitem.family,f))
6477 {
6478 return qe_invalid;
6479 }
6480 107776 }
6481 else
6482 {
6483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48384 times.
48384 if(!p_getc(&tempitem.family,f))
6484 {
6485 return qe_invalid;
6486 }
6487 }
6488
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if(s_version < 16)
6489 if(tempitem.family == 0xFF)
6490 tempitem.family = itype_misc;
6491
6492
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if(!p_getc(&tempitem.fam_type,f))
6493 {
6494 return qe_invalid;
6495 }
6496
6497
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if(s_version>5)
6498 {
6499
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 48384 times.
156160 if(s_version>=31)
6500 {
6501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107776 times.
107776 if(!p_igetl(&tempitem.power,f))
6502 {
6503 return qe_invalid;
6504 }
6505 107776 }
6506 else
6507 {
6508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48384 times.
48384 if(!p_getc(&tempitem.power,f))
6509 {
6510 return qe_invalid;
6511 }
6512 }
6513
6514 //converted flags from 16b to 32b -Z
6515
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 107776 times.
156160 if ( s_version < 41 )
6516 {
6517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48384 times.
48384 if(!p_igetw(&tempitem.flags,f))
6518 {
6519 return qe_invalid;
6520 }
6521 48384 }
6522 else
6523 {
6524
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if(!p_igetl(&tempitem.flags,f))
6525 {
6526 return qe_invalid;
6527 }
6528 }
6529 156160 }
6530 else
6531 {
6532 //tempitem.power = tempitem.fam_type;
6533 char tempchar;
6534
6535 if(!p_getc(&tempchar,f))
6536 {
6537 return qe_invalid;
6538 }
6539
6540 if (tempchar) tempitem.flags |= item_gamedata;
6541 }
6542
6543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156160 times.
156160 if(!p_igetw(&tempitem.script,f))
6544 {
6545 return qe_invalid;
6546 }
6547
6548
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if(s_version<=3)
6549 {
6550 if(tempitem.script > NUMSCRIPTITEM)
6551 {
6552 tempitem.script = 0;
6553 }
6554 }
6555
6556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156160 times.
156160 if(!p_getc(&tempitem.count,f))
6557 {
6558 return qe_invalid;
6559 }
6560
6561
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if(!p_igetw(&tempitem.amount,f))
6562 {
6563 return qe_invalid;
6564 }
6565
6566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156160 times.
156160 if(!p_igetw(&tempitem.collect_script,f))
6567 {
6568 return qe_invalid;
6569 }
6570
6571
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if(s_version<=3)
6572 {
6573 if(tempitem.collect_script > NUMSCRIPTITEM)
6574 {
6575 tempitem.collect_script = 0;
6576 }
6577 }
6578
6579
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if(!p_igetw(&tempitem.setmax,f))
6580 {
6581 return qe_invalid;
6582 }
6583
6584
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if(!p_igetw(&tempitem.max,f))
6585 {
6586 return qe_invalid;
6587 }
6588
6589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156160 times.
156160 if(!p_getc(&tempitem.playsound,f))
6590 {
6591 return qe_invalid;
6592 }
6593
6594
2/2
✓ Branch 0 taken 1249280 times.
✓ Branch 1 taken 156160 times.
1405440 for(int32_t j=0; j<8; j++)
6595 {
6596
1/2
✓ Branch 0 taken 1249280 times.
✗ Branch 1 not taken.
1249280 if(!p_igetl(&tempitem.initiald[j],f))
6597 {
6598 return qe_invalid;
6599 }
6600 1249280 }
6601
6602
2/2
✓ Branch 0 taken 312320 times.
✓ Branch 1 taken 156160 times.
468480 for(int32_t j=0; j<2; j++)
6603 {
6604
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_getc(&tempitem.initiala[j],f))
6605 {
6606 return qe_invalid;
6607 }
6608 312320 }
6609
6610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156160 times.
156160 if(s_version>4)
6611 {
6612
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if(s_version>5)
6613 {
6614
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if(!p_getc(&tempitem.wpn,f))
6615 {
6616 return qe_invalid;
6617 }
6618
6619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156160 times.
156160 if(!p_getc(&tempitem.wpn2,f))
6620 {
6621 return qe_invalid;
6622 }
6623
6624
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if(!p_getc(&tempitem.wpn3,f))
6625 {
6626 return qe_invalid;
6627 }
6628
6629
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if(!p_getc(&tempitem.wpn4,f))
6630 {
6631 return qe_invalid;
6632 }
6633
6634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156160 times.
156160 if(s_version>=15)
6635 {
6636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156160 times.
156160 if(!p_getc(&tempitem.wpn5,f))
6637 {
6638 return qe_invalid;
6639 }
6640
6641
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if(!p_getc(&tempitem.wpn6,f))
6642 {
6643 return qe_invalid;
6644 }
6645
6646
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if(!p_getc(&tempitem.wpn7,f))
6647 {
6648 return qe_invalid;
6649 }
6650
6651
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if(!p_getc(&tempitem.wpn8,f))
6652 {
6653 return qe_invalid;
6654 }
6655
6656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156160 times.
156160 if(!p_getc(&tempitem.wpn9,f))
6657 {
6658 return qe_invalid;
6659 }
6660
6661
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if(!p_getc(&tempitem.wpn10,f))
6662 {
6663 return qe_invalid;
6664 }
6665 156160 }
6666
6667
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if(!p_getc(&tempitem.pickup_hearts,f))
6668 {
6669 return qe_invalid;
6670 }
6671
6672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156160 times.
156160 if(s_version<15)
6673 {
6674 if(!p_igetw(&dummy_word,f))
6675 {
6676 return qe_invalid;
6677 }
6678
6679 tempitem.misc1=dummy_word;
6680
6681 if(!p_igetw(&dummy_word,f))
6682 {
6683 return qe_invalid;
6684 }
6685
6686 tempitem.misc2=dummy_word;
6687 }
6688 else
6689 {
6690
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if(!p_igetl(&tempitem.misc1,f))
6691 {
6692 return qe_invalid;
6693 }
6694
6695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156160 times.
156160 if(!p_igetl(&tempitem.misc2,f))
6696 {
6697 return qe_invalid;
6698 }
6699
6700 // Version 24: sh_ice -> sh_script; previously, all shields could block script weapons
6701
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if(s_version<24)
6702 {
6703 if(tempitem.family==itype_shield)
6704 {
6705 tempitem.misc1|=sh_script;
6706 }
6707 }
6708 }
6709
6710
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 107776 times.
156160 if(s_version < 53)
6711 {
6712 byte tempbyte;
6713
1/2
✓ Branch 0 taken 48384 times.
✗ Branch 1 not taken.
48384 if(!p_getc(&tempbyte,f))
6714 {
6715 return qe_invalid;
6716 }
6717 48384 tempitem.cost_amount[0] = tempbyte;
6718 48384 }
6719 else
6720 {
6721
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 107776 times.
323328 for(auto q = 0; q < 2; ++q)
6722 {
6723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 215552 times.
215552 if(!p_igetw(&tempitem.cost_amount[q],f))
6724 {
6725 return qe_invalid;
6726 }
6727 215552 }
6728 }
6729 156160 }
6730 else
6731 {
6732 char tempchar;
6733
6734 if(!p_getc(&tempchar,f))
6735 {
6736 return qe_invalid;
6737 }
6738
6739 if (tempchar) tempitem.flags |= item_edible;
6740 }
6741
6742 // June 2007: more misc. attributes
6743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156160 times.
156160 if(s_version>=12)
6744 {
6745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156160 times.
156160 if(s_version<15)
6746 {
6747 if(!p_igetw(&dummy_word,f))
6748 {
6749 return qe_invalid;
6750 }
6751
6752 tempitem.misc3=dummy_word;
6753
6754 if(!p_igetw(&dummy_word,f))
6755 {
6756 return qe_invalid;
6757 }
6758
6759 tempitem.misc4=dummy_word;
6760 }
6761 else
6762 {
6763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156160 times.
156160 if(!p_igetl(&tempitem.misc3,f))
6764 {
6765 return qe_invalid;
6766 }
6767
6768
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if(!p_igetl(&tempitem.misc4,f))
6769 {
6770 return qe_invalid;
6771 }
6772
6773
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if(!p_igetl(&tempitem.misc5,f))
6774 {
6775 return qe_invalid;
6776 }
6777
6778
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if(!p_igetl(&tempitem.misc6,f))
6779 {
6780 return qe_invalid;
6781 }
6782
6783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156160 times.
156160 if(!p_igetl(&tempitem.misc7,f))
6784 {
6785 return qe_invalid;
6786 }
6787
6788
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if(!p_igetl(&tempitem.misc8,f))
6789 {
6790 return qe_invalid;
6791 }
6792
6793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156160 times.
156160 if(!p_igetl(&tempitem.misc9,f))
6794 {
6795 return qe_invalid;
6796 }
6797
6798
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if(!p_igetl(&tempitem.misc10,f))
6799 {
6800 return qe_invalid;
6801 }
6802 }
6803
6804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156160 times.
156160 if(!p_getc(&tempitem.usesound,f))
6805 {
6806 return qe_invalid;
6807 }
6808
6809
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 48384 times.
156160 if(s_version >= 49)
6810 {
6811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107776 times.
107776 if(!p_getc(&tempitem.usesound2,f))
6812 {
6813 return qe_invalid;
6814 }
6815 107776 }
6816 48384 else tempitem.usesound2 = 0;
6817
6818
3/4
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 107776 times.
✓ Branch 2 taken 48384 times.
✗ Branch 3 not taken.
156160 if(s_version < 50 && tempitem.family == itype_mirror)
6819 {
6820 //Split continue/dmap warp effect/sfx, port for old
6821 tempitem.misc2 = tempitem.misc1;
6822 tempitem.usesound2 = tempitem.usesound;
6823 }
6824 156160 }
6825 156160 }
6826
6827
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 107776 times.
156160 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6828 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107776 times.
107776 if(!p_getc(&tempitem.useweapon,f))
6830 {
6831 return qe_invalid;
6832 }
6833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107776 times.
107776 if(!p_getc(&tempitem.usedefence,f))
6834 {
6835 return qe_invalid;
6836 }
6837
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if(!p_igetl(&tempitem.weaprange,f))
6838 {
6839 return qe_invalid;
6840 }
6841
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if(!p_igetl(&tempitem.weapduration,f))
6842 {
6843 return qe_invalid;
6844 }
6845
2/2
✓ Branch 0 taken 1077760 times.
✓ Branch 1 taken 107776 times.
1185536 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6846 {
6847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1077760 times.
1077760 if(!p_igetl(&tempitem.weap_pattern[q],f))
6848 {
6849 return qe_invalid;
6850 }
6851 1077760 }
6852 107776 }
6853
6854
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 107776 times.
156160 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6855 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6856
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if(!p_igetl(&tempitem.duplicates,f))
6857 {
6858 return qe_invalid;
6859 }
6860
2/2
✓ Branch 0 taken 862208 times.
✓ Branch 1 taken 107776 times.
969984 for ( int32_t q = 0; q < INITIAL_D; q++ )
6861 {
6862
1/2
✓ Branch 0 taken 862208 times.
✗ Branch 1 not taken.
862208 if(!p_igetl(&tempitem.weap_initiald[q],f))
6863 {
6864 return qe_invalid;
6865 }
6866 862208 }
6867
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 107776 times.
323328 for ( int32_t q = 0; q < INITIAL_A; q++ )
6868 {
6869
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_getc(&tempitem.weap_initiala[q],f))
6870 {
6871 return qe_invalid;
6872 }
6873 215552 }
6874
6875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107776 times.
107776 if(!p_getc(&tempitem.drawlayer,f))
6876 {
6877 return qe_invalid;
6878 }
6879
6880
6881
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if(!p_igetl(&tempitem.hxofs,f))
6882 {
6883 return qe_invalid;
6884 }
6885
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if(!p_igetl(&tempitem.hyofs,f))
6886 {
6887 return qe_invalid;
6888 }
6889
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if(!p_igetl(&tempitem.hxsz,f))
6890 {
6891 return qe_invalid;
6892 }
6893
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if(!p_igetl(&tempitem.hysz,f))
6894 {
6895 return qe_invalid;
6896 }
6897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107776 times.
107776 if(!p_igetl(&tempitem.hzsz,f))
6898 {
6899 return qe_invalid;
6900 }
6901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107776 times.
107776 if(!p_igetl(&tempitem.xofs,f))
6902 {
6903 return qe_invalid;
6904 }
6905
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if(!p_igetl(&tempitem.yofs,f))
6906 {
6907 return qe_invalid;
6908 }
6909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107776 times.
107776 if(!p_igetl(&tempitem.weap_hxofs,f))
6910 {
6911 return qe_invalid;
6912 }
6913
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if(!p_igetl(&tempitem.weap_hyofs,f))
6914 {
6915 return qe_invalid;
6916 }
6917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107776 times.
107776 if(!p_igetl(&tempitem.weap_hxsz,f))
6918 {
6919 return qe_invalid;
6920 }
6921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107776 times.
107776 if(!p_igetl(&tempitem.weap_hysz,f))
6922 {
6923 return qe_invalid;
6924 }
6925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107776 times.
107776 if(!p_igetl(&tempitem.weap_hzsz,f))
6926 {
6927 return qe_invalid;
6928 }
6929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107776 times.
107776 if(!p_igetl(&tempitem.weap_xofs,f))
6930 {
6931 return qe_invalid;
6932 }
6933
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if(!p_igetl(&tempitem.weap_yofs,f))
6934 {
6935 return qe_invalid;
6936 }
6937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107776 times.
107776 if(!p_igetw(&tempitem.weaponscript,f))
6938 {
6939 return qe_invalid;
6940 }
6941
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if(!p_igetl(&tempitem.wpnsprite,f))
6942 {
6943 return qe_invalid;
6944 }
6945 107776 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6946
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 107776 times.
323328 for(auto q = 0; q < num_cost_tmr; ++q)
6947 {
6948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 215552 times.
215552 if(!p_igetl(&tempitem.magiccosttimer[q],f))
6949 {
6950 return qe_invalid;
6951 }
6952 215552 }
6953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107776 times.
107776 for(auto q = num_cost_tmr; q < 2; ++q)
6954 tempitem.magiccosttimer[q] = 0;
6955 107776 }
6956
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 107776 times.
156160 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6957 {
6958 //Item Size FLags, TileWidth, TileHeight
6959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107776 times.
107776 if(!p_igetl(&tempitem.overrideFLAGS,f))
6960 {
6961 return qe_invalid;
6962 }
6963
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if(!p_igetl(&tempitem.tilew,f))
6964 {
6965 return qe_invalid;
6966 }
6967
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if(!p_igetl(&tempitem.tileh,f))
6968 {
6969 return qe_invalid;
6970 }
6971 107776 }
6972
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 107776 times.
156160 if ( s_version >= 29 ) //! More new vars.
6973 {
6974 //Item Size FLags, TileWidth, TileHeight
6975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107776 times.
107776 if(!p_igetl(&tempitem.weapoverrideFLAGS,f))
6976 {
6977 return qe_invalid;
6978 }
6979
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if(!p_igetl(&tempitem.weap_tilew,f))
6980 {
6981 return qe_invalid;
6982 }
6983
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if(!p_igetl(&tempitem.weap_tileh,f))
6984 {
6985 return qe_invalid;
6986 }
6987 107776 }
6988
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 107776 times.
156160 if ( s_version >= 30 ) //! More new vars.
6989 {
6990 //Pickup Type
6991
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if(!p_igetl(&tempitem.pickup,f))
6992 {
6993 return qe_invalid;
6994 }
6995 107776 }
6996
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 107776 times.
156160 if ( s_version >= 32 ) //! More new vars.
6997 {
6998 //Pickup Type
6999
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if(!p_igetw(&tempitem.pstring,f))
7000 {
7001 return qe_invalid;
7002 }
7003 107776 }
7004
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 107776 times.
156160 if ( s_version >= 33 ) //! More new vars.
7005 {
7006 //Pickup Type
7007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107776 times.
107776 if(!p_igetw(&tempitem.pickup_string_flags,f))
7008 {
7009 return qe_invalid;
7010 }
7011 107776 }
7012
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 107776 times.
156160 if ( s_version >= 34 ) //! cost counter
7013 {
7014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107776 times.
107776 if(s_version < 53)
7015 {
7016 if(!p_getc(&tempitem.cost_counter[0],f))
7017 {
7018 return qe_invalid;
7019 }
7020 }
7021 else
7022 {
7023
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 107776 times.
323328 for(auto q = 0; q < 2; ++q)
7024 {
7025
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_getc(&tempitem.cost_counter[q],f))
7026 {
7027 return qe_invalid;
7028 }
7029 215552 }
7030 }
7031 107776 }
7032
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 107776 times.
156160 if ( s_version >= 44 ) //! sprite scripts
7033 {
7034
2/2
✓ Branch 0 taken 862208 times.
✓ Branch 1 taken 107776 times.
969984 for ( int32_t q = 0; q < 8; q++ )
7035 {
7036
2/2
✓ Branch 0 taken 56043520 times.
✓ Branch 1 taken 862208 times.
56905728 for ( int32_t w = 0; w < 65; w++ )
7037 {
7038
1/2
✓ Branch 0 taken 56043520 times.
✗ Branch 1 not taken.
56043520 if(!p_getc(&(tempitem.initD_label[q][w]),f))
7039 {
7040 return qe_invalid;
7041 }
7042 56043520 }
7043
2/2
✓ Branch 0 taken 56043520 times.
✓ Branch 1 taken 862208 times.
56905728 for ( int32_t w = 0; w < 65; w++ )
7044 {
7045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56043520 times.
56043520 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f))
7046 {
7047 return qe_invalid;
7048 }
7049 56043520 }
7050
2/2
✓ Branch 0 taken 56043520 times.
✓ Branch 1 taken 862208 times.
56905728 for ( int32_t w = 0; w < 65; w++ )
7051 {
7052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56043520 times.
56043520 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f))
7053 {
7054 return qe_invalid;
7055 }
7056 56043520 }
7057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 862208 times.
862208 if(!p_igetl(&(tempitem.sprite_initiald[q]),f))
7058 {
7059 return qe_invalid;
7060 }
7061
7062 862208 }
7063
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 107776 times.
323328 for ( int32_t q = 0; q < 2; q++ )
7064 {
7065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 215552 times.
215552 if(!p_getc(&(tempitem.sprite_initiala[q]),f))
7066 {
7067 return qe_invalid;
7068 }
7069 215552 }
7070 //Pickup Type
7071
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if(!p_igetw(&tempitem.sprite_script,f))
7072 {
7073 return qe_invalid;
7074 }
7075 107776 }
7076
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 107776 times.
156160 if ( s_version >= 48 ) //! pickup flags
7077 {
7078
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if(!p_getc(&(tempitem.pickupflag),f))
7079 {
7080 return qe_invalid;
7081 }
7082 107776 }
7083
2/2
✓ Branch 0 taken 51712 times.
✓ Branch 1 taken 104448 times.
156160 if ( s_version >= 57 )
7084 {
7085 104448 std::string str;
7086
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 104448 times.
✓ Branch 2 taken 104448 times.
✗ Branch 3 not taken.
104448 if(!p_getcstr(&str,f))
7087 return qe_invalid;
7088 104448 strncpy(tempitem.display_name,str.c_str(),255);
7089
1/3
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
104448 }
7090 156160 }
7091 else
7092 {
7093 4130 tempitem.count=-1;
7094 4130 tempitem.family=itype_misc;
7095 4130 tempitem.flags=item_none;
7096 4130 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7097 4130 tempitem.playsound=WAV_SCALE;
7098 4130 reset_itembuf(&tempitem,i);
7099 }
7100
7101
2/2
✓ Branch 0 taken 57122 times.
✓ Branch 1 taken 103168 times.
160290 if(s_version >= 58)
7102 {
7103
2/2
✓ Branch 0 taken 515840 times.
✓ Branch 1 taken 103168 times.
619008 for(int q = 0; q < BURNSPR_MAX; ++q)
7104 {
7105
1/2
✓ Branch 0 taken 515840 times.
✗ Branch 1 not taken.
515840 if(!p_getc(&tempitem.burnsprs[q],f))
7106 return qe_invalid;
7107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 515840 times.
515840 if(s_version >= 59)
7108
1/2
✓ Branch 0 taken 515840 times.
✗ Branch 1 not taken.
515840 if(!p_getc(&tempitem.light_rads[q],f))
7109 return qe_invalid;
7110 515840 }
7111 103168 }
7112
7113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160290 times.
160290 if (!should_skip)
7114 {
7115
1/2
✓ Branch 0 taken 160290 times.
✗ Branch 1 not taken.
160290 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
7116 {
7117 tempitem.script = 0;
7118 tempitem.weaponscript = 0;
7119 for(int q = 0; q < 8; ++q)
7120 {
7121 tempitem.initiald[q] = 0;
7122 tempitem.weap_initiald[q] = 0;
7123 }
7124 }
7125 160290 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7126 160290 }
7127 160290 }
7128
7129
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 692 times.
693 if (should_skip)
7130 1 return 0;
7131
7132 //////////////////////////////////////////////////////
7133 // Now do any updates because of new item additions
7134 // (These can't be done above because items_to_read
7135 // might be too low.)
7136 //////////////////////////////////////////////////////
7137
2/2
✓ Branch 0 taken 177152 times.
✓ Branch 1 taken 692 times.
177844 for(int32_t i=0; i<MAXITEMS; i++)
7138 {
7139 177152 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7140
7141 //Account for older quests that didn't have an actual item for the used letter
7142
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 156160 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
177152 if(s_version < 2 && i==iLetterUsed)
7143 {
7144 82 reset_itembuf(&tempitem, iLetterUsed);
7145 82 strcpy(item_string[i],old_item_string[i]);
7146 82 tempitem.tile = itemsbuf[iLetter].tile;
7147 82 tempitem.csets = itemsbuf[iLetter].csets;
7148 82 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7149 82 tempitem.frames = itemsbuf[iLetter].frames;
7150 82 tempitem.speed = itemsbuf[iLetter].speed;
7151 82 tempitem.ltm = itemsbuf[iLetter].ltm;
7152 82 }
7153
7154
2/2
✓ Branch 0 taken 156160 times.
✓ Branch 1 taken 20992 times.
177152 if(s_version < 3)
7155 {
7156
3/3
✓ Branch 0 taken 1804 times.
✓ Branch 1 taken 19106 times.
✓ Branch 2 taken 82 times.
20992 switch(i)
7157 {
7158 case iRocsFeather:
7159 case iHoverBoots:
7160 case iSpinScroll:
7161 case iL2SpinScroll:
7162 case iCrossScroll:
7163 case iQuakeScroll:
7164 case iL2QuakeScroll:
7165 case iWhispRing:
7166 case iL2WhispRing:
7167 case iChargeRing:
7168 case iL2ChargeRing:
7169 case iPerilScroll:
7170 case iWalletL3:
7171 case iQuiverL4:
7172 case iBombBagL4:
7173 case iBracelet:
7174 case iL2Bracelet:
7175 case iOldGlove:
7176 case iL2Ladder:
7177 case iWealthMedal:
7178 case iL2WealthMedal:
7179 case iL3WealthMedal:
7180 1804 reset_itembuf(&tempitem, i);
7181 1804 strcpy(item_string[i],old_item_string[i]);
7182 1804 break;
7183
7184 case iSShield:
7185 82 reset_itembuf(&tempitem, i);
7186 82 strcpy(item_string[i],old_item_string[i]);
7187 82 strcpy(item_string[iShield],old_item_string[iShield]);
7188 82 strcpy(item_string[iMShield],old_item_string[iMShield]);
7189 82 break;
7190 }
7191 20992 }
7192
7193
2/2
✓ Branch 0 taken 156160 times.
✓ Branch 1 taken 20992 times.
177152 if(s_version < 5)
7194 {
7195
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 20418 times.
20992 switch(i)
7196 {
7197 case iHeartRing:
7198 case iL2HeartRing:
7199 case iL3HeartRing:
7200 case iMagicRing:
7201 case iL2MagicRing:
7202 case iL3MagicRing:
7203 case iL4MagicRing:
7204 574 reset_itembuf(&tempitem, i);
7205 574 strcpy(item_string[i],old_item_string[i]);
7206 574 break;
7207 }
7208 20992 }
7209
7210
2/2
✓ Branch 0 taken 156160 times.
✓ Branch 1 taken 20992 times.
177152 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7211 {
7212
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(i!=iBPotion && i!=iRPotion)
7213
2/2
✓ Branch 0 taken 19304 times.
✓ Branch 1 taken 1524 times.
20828 if (get_bit(deprecated_rules,32)) tempitem.flags |= item_keep_old;
7214
7215
43/43
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 328 times.
✓ Branch 8 taken 17302 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 82 times.
✓ Branch 11 taken 82 times.
✓ Branch 12 taken 82 times.
✓ Branch 13 taken 82 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
✓ Branch 16 taken 82 times.
✓ Branch 17 taken 82 times.
✓ Branch 18 taken 82 times.
✓ Branch 19 taken 82 times.
✓ Branch 20 taken 82 times.
✓ Branch 21 taken 82 times.
✓ Branch 22 taken 82 times.
✓ Branch 23 taken 82 times.
✓ Branch 24 taken 82 times.
✓ Branch 25 taken 82 times.
✓ Branch 26 taken 82 times.
✓ Branch 27 taken 82 times.
✓ Branch 28 taken 82 times.
✓ Branch 29 taken 82 times.
✓ Branch 30 taken 82 times.
✓ Branch 31 taken 82 times.
✓ Branch 32 taken 82 times.
✓ Branch 33 taken 82 times.
✓ Branch 34 taken 82 times.
✓ Branch 35 taken 82 times.
✓ Branch 36 taken 82 times.
✓ Branch 37 taken 82 times.
✓ Branch 38 taken 82 times.
✓ Branch 39 taken 82 times.
✓ Branch 40 taken 82 times.
✓ Branch 41 taken 82 times.
✓ Branch 42 taken 82 times.
20992 switch(i)
7216 {
7217 case iTriforce:
7218 82 tempitem.fam_type=1;
7219 82 break;
7220
7221 case iBigTri:
7222 82 tempitem.fam_type=0;
7223 82 break;
7224
7225 case iBombs:
7226 82 tempitem.fam_type=i_bomb;
7227 82 tempitem.power=4;
7228 82 tempitem.wpn=wBOMB;
7229 82 tempitem.wpn2=wBOOM;
7230 82 tempitem.misc1 = 50;
7231
7232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7233
7234 82 break;
7235
7236 case iSBomb:
7237 82 tempitem.fam_type=i_sbomb;
7238 82 tempitem.power=16;
7239 82 tempitem.wpn=wSBOMB;
7240 82 tempitem.wpn2=wSBOOM;
7241 82 tempitem.misc1 = 50;
7242
7243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7244
7245 82 break;
7246
7247 case iBook:
7248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7249 tempitem.wpn = wFIREMAGIC;
7250
7251 82 break;
7252
7253 case iSArrow:
7254 82 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7255 82 tempitem.power=4;
7256 82 tempitem.flags|=item_gamedata;
7257 82 tempitem.wpn=wSARROW;
7258 82 break;
7259
7260 case iGArrow:
7261 82 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7262 82 tempitem.power=8;
7263 82 tempitem.flags|=(item_gamedata|item_flag1);
7264 82 tempitem.wpn=wGARROW;
7265 82 break;
7266
7267 case iBrang:
7268 82 tempitem.power=0;
7269 82 tempitem.wpn=wBRANG;
7270 82 tempitem.misc1=36;
7271 82 break;
7272
7273 case iMBrang:
7274 82 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7275 82 tempitem.power=0;
7276 82 tempitem.wpn=wMBRANG;
7277 82 break;
7278
7279 case iFBrang:
7280 82 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7281 82 tempitem.power=2;
7282 82 tempitem.wpn=wFBRANG;
7283 82 break;
7284
7285 case iBoots:
7286 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7287 82 tempitem.power=7;
7288 82 break;
7289
7290 case iWand:
7291 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7292 82 tempitem.power=2;
7293 82 tempitem.wpn=wWAND;
7294 82 tempitem.wpn3=wMAGIC;
7295 82 break;
7296
7297 case iBCandle:
7298 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7299 82 tempitem.power=1;
7300 82 tempitem.flags|=(item_gamedata|item_flag1);
7301 82 tempitem.wpn3=wFIRE;
7302 82 break;
7303
7304 case iRCandle:
7305 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7306 82 tempitem.power=1;
7307 82 tempitem.wpn3=wFIRE;
7308 82 break;
7309
7310 case iSword:
7311 82 tempitem.power=1;
7312 82 tempitem.flags|= item_flag4 |item_flag2;
7313 82 tempitem.wpn=tempitem.wpn3=wSWORD;
7314 82 tempitem.wpn2=wSWORDSLASH;
7315 82 break;
7316
7317 case iWSword:
7318 82 tempitem.power=2;
7319 82 tempitem.flags|= item_flag4 |item_flag2;
7320 82 tempitem.wpn=tempitem.wpn3=wWSWORD;
7321 82 tempitem.wpn2=wWSWORDSLASH;
7322 82 break;
7323
7324 case iMSword:
7325 82 tempitem.power=4;
7326 82 tempitem.flags|= item_flag4 |item_flag2;
7327 82 tempitem.wpn=tempitem.wpn3=wMSWORD;
7328 82 tempitem.wpn2=wMSWORDSLASH;
7329 82 break;
7330
7331 case iXSword:
7332 82 tempitem.power=8;
7333 82 tempitem.flags|= item_flag4 |item_flag2;
7334 82 tempitem.wpn=tempitem.wpn3=wXSWORD;
7335 82 tempitem.wpn2=wXSWORDSLASH;
7336 82 break;
7337
7338 case iDivineProtection:
7339 82 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? item_flag1 : item_none;
7340 82 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? item_flag2 : item_none;
7341 82 tempitem.wpn=wDIVINEPROTECTION1A;
7342 82 tempitem.wpn2=wDIVINEPROTECTION1B;
7343 82 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7344 82 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7345 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7346 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7347 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7348 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7349 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7350 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7351 82 tempitem.misc1=512;
7352 82 tempitem.cost_amount[0]=64;
7353 82 break;
7354
7355 case iLens:
7356 82 tempitem.misc1=60;
7357 82 tempitem.flags |= get_qr(qr_ENABLEMAGIC) ? item_none : item_rupee_magic;
7358 82 tempitem.cost_amount[0] = get_qr(qr_ENABLEMAGIC) ? 2 : 1;
7359 82 break;
7360
7361 case iArrow:
7362 82 tempitem.power=2;
7363 82 tempitem.wpn=wARROW;
7364 82 break;
7365
7366 case iHoverBoots:
7367 82 tempitem.misc1=45;
7368 82 tempitem.wpn=iwHover;
7369 82 break;
7370
7371 case iDivineFire:
7372 82 tempitem.power=8;
7373 82 tempitem.wpn=wDIVINEFIRE1A;
7374 82 tempitem.wpn2=wDIVINEFIRE1B;
7375 82 tempitem.wpn3=wDIVINEFIRES1A;
7376 82 tempitem.wpn4=wDIVINEFIRES1B;
7377 82 tempitem.misc1 = 32;
7378 82 tempitem.misc2 = 200;
7379 82 tempitem.cost_amount[0]=32;
7380 82 break;
7381
7382 case iDivineEscape:
7383 82 tempitem.cost_amount[0]=32;
7384 82 break;
7385
7386 case iHookshot:
7387 82 tempitem.power=0;
7388 82 tempitem.flags&=~item_flag1;
7389 82 tempitem.wpn=wHSHEAD;
7390 82 tempitem.wpn2=wHSCHAIN_H;
7391 82 tempitem.wpn4=wHSHANDLE;
7392 82 tempitem.wpn3=wHSCHAIN_V;
7393 82 tempitem.misc1=50;
7394 82 tempitem.misc2=100;
7395 82 break;
7396
7397 case iLongshot:
7398 82 tempitem.power=0;
7399 82 tempitem.flags&=~item_flag1;
7400 82 tempitem.wpn=wLSHEAD;
7401 82 tempitem.wpn2=wLSCHAIN_H;
7402 82 tempitem.wpn4=wLSHANDLE;
7403 82 tempitem.wpn3=wLSCHAIN_V;
7404 82 tempitem.misc1=99;
7405 82 tempitem.misc2=100;
7406 82 break;
7407
7408 case iHammer:
7409 82 tempitem.power=4;
7410 82 tempitem.wpn=wHAMMER;
7411 82 tempitem.wpn2=iwHammerSmack;
7412 82 break;
7413
7414 case iCByrna:
7415 82 tempitem.power=1;
7416 82 tempitem.wpn=wCBYRNA;
7417 82 tempitem.wpn2=wCBYRNASLASH;
7418 82 tempitem.wpn3=wCBYRNAORB;
7419 82 tempitem.misc1=4;
7420 82 tempitem.misc2=16;
7421 82 tempitem.misc3=1;
7422 82 tempitem.cost_amount[0]=1;
7423 82 break;
7424
7425 case iWhistle:
7426 82 tempitem.wpn=wWIND;
7427 82 tempitem.misc1=3;
7428 82 tempitem.flags|=item_flag1;
7429 82 break;
7430
7431 case iBRing:
7432 82 tempitem.power=2;
7433 82 tempitem.misc1=spBLUE;
7434 82 break;
7435
7436 case iRRing:
7437 82 tempitem.power=4;
7438 82 tempitem.misc1=spRED;
7439 82 break;
7440
7441 case iGRing:
7442 82 tempitem.power=8;
7443 82 tempitem.misc1=spGOLD;
7444 82 break;
7445
7446 case iSpinScroll:
7447 82 tempitem.power = 2;
7448 82 tempitem.misc1 = 1;
7449 82 break;
7450
7451 case iL2SpinScroll:
7452 82 tempitem.family=itype_spinscroll2;
7453 82 tempitem.fam_type=1;
7454 82 tempitem.cost_amount[0]=8;
7455 82 tempitem.power=2;
7456 82 tempitem.misc1 = 20;
7457 82 break;
7458
7459 case iQuakeScroll:
7460 82 tempitem.misc1=0x10;
7461 82 tempitem.misc2=64;
7462 82 break;
7463
7464 case iL2QuakeScroll:
7465 82 tempitem.family=itype_quakescroll2;
7466 82 tempitem.fam_type=1;
7467 82 tempitem.power = 2;
7468 82 tempitem.misc1=0x20;
7469 82 tempitem.misc2=192;
7470 82 tempitem.cost_amount[0]=8;
7471 82 break;
7472
7473 case iChargeRing:
7474 82 tempitem.misc1=64;
7475 82 tempitem.misc2=128;
7476 82 break;
7477
7478 case iL2ChargeRing:
7479 82 tempitem.misc1=32;
7480 82 tempitem.misc2=64;
7481 82 break;
7482
7483 case iOldGlove:
7484 82 tempitem.flags |= item_flag1;
7485
7486 //fallthrough
7487 case iBombBagL4:
7488 case iWalletL3:
7489 case iQuiverL4:
7490 case iBracelet:
7491 410 tempitem.power = 1;
7492 410 break;
7493
7494 case iL2Bracelet:
7495 82 tempitem.power = 2;
7496 82 break;
7497
7498 case iMKey:
7499 82 tempitem.power=0xFF;
7500 82 tempitem.flags |= item_flag1;
7501 82 break;
7502 }
7503 20992 }
7504
7505
2/2
✓ Branch 0 taken 156160 times.
✓ Branch 1 taken 20992 times.
177152 if(s_version < 7)
7506 {
7507
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 20664 times.
20992 switch(i)
7508 {
7509 case iStoneAgony:
7510 case iStompBoots:
7511 case iPerilRing:
7512 case iWhimsicalRing:
7513 {
7514 328 reset_itembuf(&tempitem, i);
7515 328 strcpy(item_string[i],old_item_string[i]);
7516 328 break;
7517 }
7518 }
7519 20992 }
7520
7521
2/2
✓ Branch 0 taken 156160 times.
✓ Branch 1 taken 20992 times.
177152 if(s_version < 8) // May 2007: Some corrections.
7522 {
7523
7/7
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 20336 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
20992 switch(i)
7524 {
7525 case iMShield:
7526 82 tempitem.misc1|=sh_flame;
7527 82 tempitem.misc2|=sh_fireball|sh_magic;
7528
7529
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(get_qr(qr_SWORDMIRROR))
7530 {
7531 tempitem.misc2 |= sh_sword;
7532 }
7533
7534 // fallthrough
7535 case iShield:
7536 164 tempitem.misc1|=sh_fireball|sh_sword|sh_magic;
7537
7538 // fallthrough
7539 case iSShield:
7540 246 tempitem.misc1|=sh_rock|sh_arrow|sh_brang|sh_script;
7541
7542
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7543 {
7544 tempitem.misc2 |= sh_rock;
7545 }
7546
7547 246 break;
7548
7549 case iWhispRing:
7550 82 tempitem.power=1;
7551 82 tempitem.flags|=item_gamedata|item_flag1;
7552 82 tempitem.misc1 = 3;
7553 82 break;
7554
7555 case iL2WhispRing:
7556 82 tempitem.power=0;
7557 82 tempitem.flags|=item_gamedata|item_flag1;
7558 82 tempitem.misc1 = 3;
7559 82 break;
7560
7561 case iL2Ladder:
7562 case iBow:
7563 case iCByrna:
7564 246 tempitem.power = 1;
7565 246 break;
7566 }
7567 20992 }
7568
7569
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 156160 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
177152 if(s_version < 9 && i==iClock)
7570 {
7571 82 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7572 82 }
7573
7574 //add the misc flag for bomb
7575
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 156160 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
177152 if(s_version < 10 && tempitem.family == itype_bomb)
7576 {
7577 82 tempitem.flags = (tempitem.flags & ~item_flag1) | (get_qr(qr_LONGBOMBBOOM_DEP) ? item_flag1 : item_none);
7578 82 }
7579
7580
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 156160 times.
✓ Branch 2 taken 20828 times.
✓ Branch 3 taken 164 times.
177152 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7581 {
7582 164 tempitem.flags = (tempitem.fam_type ? item_gamedata : item_none);
7583 164 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7584 164 }
7585
7586
2/2
✓ Branch 0 taken 156160 times.
✓ Branch 1 taken 20992 times.
177152 if(s_version < 12) // June 2007: More Misc. attributes.
7587 {
7588
5/5
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20582 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
20992 switch(i)
7589 {
7590 case iFBrang:
7591 82 tempitem.misc4 |= sh_fireball|sh_sword|sh_magic;
7592
7593 //fallthrough
7594 case iMBrang:
7595 164 tempitem.misc3 |= sh_sword|sh_magic;
7596
7597 //fallthrough
7598 case iHookshot:
7599 case iLongshot:
7600 //fallthrough
7601 328 tempitem.misc3 |= sh_fireball;
7602
7603 case iBrang:
7604 410 tempitem.misc3 |= sh_brang|sh_rock|sh_arrow;
7605 410 break;
7606 }
7607
7608
16/16
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 246 times.
✓ Branch 4 taken 246 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 328 times.
✓ Branch 9 taken 164 times.
✓ Branch 10 taken 9629 times.
✓ Branch 11 taken 164 times.
✓ Branch 12 taken 246 times.
✓ Branch 13 taken 9313 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
20992 switch(tempitem.family)
7609 {
7610 case itype_hoverboots:
7611 82 tempitem.usesound = WAV_ZN1HOVER;
7612 82 break;
7613
7614 case itype_wand:
7615 82 tempitem.usesound = WAV_WAND;
7616 82 break;
7617
7618 case itype_book:
7619 82 tempitem.usesound = WAV_FIRE;
7620 82 break;
7621
7622 case itype_arrow:
7623 246 tempitem.usesound = WAV_ARROW;
7624 246 break;
7625
7626 case itype_hookshot:
7627 164 tempitem.usesound = WAV_HOOKSHOT;
7628 164 break;
7629
7630 case itype_brang:
7631 246 tempitem.usesound = WAV_BRANG;
7632 246 break;
7633
7634 case itype_shield:
7635 246 tempitem.usesound = WAV_CHINK;
7636 246 break;
7637
7638 case itype_sword:
7639 9313 tempitem.usesound = WAV_SWORD;
7640 9313 break;
7641
7642 case itype_whistle:
7643 82 tempitem.usesound = WAV_WHISTLE;
7644 82 break;
7645
7646 case itype_hammer:
7647 82 tempitem.usesound = WAV_HAMMER;
7648 82 break;
7649
7650 case itype_divinefire:
7651 82 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7652 82 break;
7653
7654 case itype_divineescape:
7655 82 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7656 82 break;
7657
7658 case itype_divineprotection:
7659 82 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7660 82 break;
7661
7662 case itype_bomb:
7663 case itype_sbomb:
7664 case itype_quakescroll:
7665 case itype_quakescroll2:
7666 328 tempitem.usesound = WAV_BOMB;
7667 328 break;
7668
7669 case itype_spinscroll:
7670 case itype_spinscroll2:
7671 164 tempitem.usesound = WAV_ZN1SPINATTACK;
7672 164 break;
7673 }
7674 20992 }
7675
7676
2/2
✓ Branch 0 taken 156160 times.
✓ Branch 1 taken 20992 times.
177152 if(s_version < 13) // July 2007
7677 {
7678
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_whistle)
7679 {
7680 82 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7681 82 tempitem.power = 1;
7682 82 tempitem.flags|=item_flag1;
7683 82 }
7684
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.family == itype_wand)
7685 82 tempitem.flags|=item_flag1;
7686
2/2
✓ Branch 0 taken 20746 times.
✓ Branch 1 taken 82 times.
20828 else if(tempitem.family == itype_book)
7687 {
7688 82 tempitem.flags|=item_flag1;
7689 82 tempitem.power = 2;
7690 82 }
7691 20992 }
7692
7693
2/2
✓ Branch 0 taken 156160 times.
✓ Branch 1 taken 20992 times.
177152 if(s_version < 14) // August 2007
7694 {
7695
2/2
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
20992 if(tempitem.family == itype_fairy)
7696 {
7697 164 tempitem.usesound = WAV_SCALE;
7698
7699
1/2
✓ Branch 0 taken 164 times.
✗ Branch 1 not taken.
164 if(tempitem.fam_type)
7700 164 tempitem.misc3=50;
7701 164 }
7702
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.family == itype_potion)
7703 {
7704 164 tempitem.flags |= item_gain_old;
7705 164 }
7706 20992 }
7707
7708
2/2
✓ Branch 0 taken 156160 times.
✓ Branch 1 taken 20992 times.
177152 if(s_version < 17) // November 2007
7709 {
7710
3/4
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
✓ Branch 2 taken 164 times.
✗ Branch 3 not taken.
20992 if(tempitem.family == itype_candle && !tempitem.wpn3)
7711 {
7712 tempitem.wpn3 = wFIRE;
7713 }
7714
4/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 20746 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 82 times.
20992 else if(tempitem.family == itype_arrow && tempitem.power>4)
7715 {
7716 82 tempitem.flags|=item_flag1;
7717 82 }
7718 20992 }
7719
7720
2/2
✓ Branch 0 taken 156160 times.
✓ Branch 1 taken 20992 times.
177152 if(s_version < 18) // New Year's Eve 2007
7721 {
7722
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_whistle)
7723 82 tempitem.misc2 = 8; // Use the Whistle warp ring
7724
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.family == itype_bait)
7725 82 tempitem.misc1 = 768; // Frames until it goes
7726
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.family == itype_triforcepiece)
7727 {
7728
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
164 if(tempitem.flags & item_gamedata)
7729 {
7730 82 tempitem.misc2 = 1; // Cutscene 1
7731 82 tempitem.flags |= item_flag1; // Side Warp Out
7732 82 }
7733 164 }
7734 20992 }
7735
7736
2/2
✓ Branch 0 taken 156160 times.
✓ Branch 1 taken 20992 times.
177152 if(s_version < 19) // January 2008
7737 {
7738
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divineprotection)
7739 {
7740
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 80 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)) tempitem.flags |= item_flag3;
7741
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 72 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)) tempitem.flags |= item_flag4;
7742 82 }
7743 20992 }
7744
7745
2/2
✓ Branch 0 taken 156160 times.
✓ Branch 1 taken 20992 times.
177152 if(s_version < 20) // October 2008
7746 {
7747
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divineprotection)
7748 {
7749 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7750 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7751 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7752 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7753 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7754 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7755 82 }
7756 20992 }
7757
7758
2/2
✓ Branch 0 taken 156160 times.
✓ Branch 1 taken 20992 times.
177152 if(s_version < 21) // November 2008
7759 {
7760
1/2
✓ Branch 0 taken 20992 times.
✗ Branch 1 not taken.
20992 if(tempitem.flags & 0x0100) // item_slash
7761 {
7762 tempitem.flags &= ~item_unused;
7763
7764 if(tempitem.family == itype_sword ||
7765 tempitem.family == itype_wand ||
7766 tempitem.family == itype_candle ||
7767 tempitem.family == itype_cbyrna)
7768 {
7769 tempitem.flags |= item_flag4;
7770 }
7771 }
7772 20992 }
7773
7774
2/2
✓ Branch 0 taken 156160 times.
✓ Branch 1 taken 20992 times.
177152 if(s_version < 22) // September 2009
7775 {
7776
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7777 {
7778 164 tempitem.misc3 = tempitem.power/2;
7779 164 }
7780 20992 }
7781
7782
2/2
✓ Branch 0 taken 156160 times.
✓ Branch 1 taken 20992 times.
177152 if(s_version < 23) // March 2011
7783 {
7784
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_divinefire)
7785 82 tempitem.wpn5 = wFIRE;
7786
2/2
✓ Branch 0 taken 20828 times.
✓ Branch 1 taken 82 times.
20910 else if(tempitem.family == itype_book)
7787 82 tempitem.wpn2 = wFIRE;
7788 20992 }
7789
7790 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7791 // whether it was or not, and a lot of existing quests depended on the
7792 // incorrect behavior.
7793
2/2
✓ Branch 0 taken 156160 times.
✓ Branch 1 taken 20992 times.
177152 if(s_version < 25) // January 2012
7794 {
7795
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 328 times.
20992 if(tempitem.family == itype_bombbag)
7796 328 tempitem.flags |= item_flag1;
7797
7798
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divinefire)
7799 82 tempitem.flags |= item_flag3; // Sideview gravity flag
7800 20992 }
7801
7802
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 69376 times.
177152 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7803 {
7804
60/60
✓ Branch 0 taken 17515 times.
✓ Branch 1 taken 813 times.
✓ Branch 2 taken 801 times.
✓ Branch 3 taken 580 times.
✓ Branch 4 taken 317 times.
✓ Branch 5 taken 271 times.
✓ Branch 6 taken 538 times.
✓ Branch 7 taken 593 times.
✓ Branch 8 taken 287 times.
✓ Branch 9 taken 861 times.
✓ Branch 10 taken 861 times.
✓ Branch 11 taken 534 times.
✓ Branch 12 taken 821 times.
✓ Branch 13 taken 538 times.
✓ Branch 14 taken 269 times.
✓ Branch 15 taken 538 times.
✓ Branch 16 taken 285 times.
✓ Branch 17 taken 269 times.
✓ Branch 18 taken 813 times.
✓ Branch 19 taken 271 times.
✓ Branch 20 taken 273 times.
✓ Branch 21 taken 540 times.
✓ Branch 22 taken 245 times.
✓ Branch 23 taken 271 times.
✓ Branch 24 taken 269 times.
✓ Branch 25 taken 269 times.
✓ Branch 26 taken 269 times.
✓ Branch 27 taken 285 times.
✓ Branch 28 taken 271 times.
✓ Branch 29 taken 271 times.
✓ Branch 30 taken 269 times.
✓ Branch 31 taken 273 times.
✓ Branch 32 taken 538 times.
✓ Branch 33 taken 1076 times.
✓ Branch 34 taken 759 times.
✓ Branch 35 taken 269 times.
✓ Branch 36 taken 523 times.
✓ Branch 37 taken 1076 times.
✓ Branch 38 taken 269 times.
✓ Branch 39 taken 269 times.
✓ Branch 40 taken 269 times.
✓ Branch 41 taken 269 times.
✓ Branch 42 taken 269 times.
✓ Branch 43 taken 540 times.
✓ Branch 44 taken 538 times.
✓ Branch 45 taken 269 times.
✓ Branch 46 taken 809 times.
✓ Branch 47 taken 811 times.
✓ Branch 48 taken 1084 times.
✓ Branch 49 taken 269 times.
✓ Branch 50 taken 269 times.
✓ Branch 51 taken 269 times.
✓ Branch 52 taken 269 times.
✓ Branch 53 taken 269 times.
✓ Branch 54 taken 295 times.
✓ Branch 55 taken 9413 times.
✓ Branch 56 taken 2766 times.
✓ Branch 57 taken 811 times.
✓ Branch 58 taken 3150 times.
✓ Branch 59 taken 10679 times.
69376 switch(tempitem.family)
7805 {
7806 case itype_sword:
7807 {
7808 17515 tempitem.flags &= ~(item_flag5);
7809 17515 tempitem.misc3 = 0;
7810 17515 tempitem.misc4 = 0;
7811 17515 tempitem.misc5 = 0;
7812 17515 tempitem.misc6 = 0;
7813 17515 tempitem.misc7 = 0;
7814 17515 tempitem.misc8 = 0;
7815 17515 tempitem.misc9 = 0;
7816 17515 tempitem.misc10 = 0;
7817 17515 tempitem.wpn4 = 0;
7818 17515 tempitem.wpn5 = 0;
7819 17515 tempitem.wpn6 = 0;
7820 17515 tempitem.wpn7 = 0;
7821 17515 tempitem.wpn8 = 0;
7822 17515 tempitem.wpn9 = 0;
7823 17515 tempitem.wpn10 = 0;
7824 17515 break;
7825 }
7826 case itype_brang:
7827 {
7828 813 tempitem.flags &= ~(item_flag4 | item_flag5);
7829 813 tempitem.misc2 = 0;
7830 813 tempitem.misc5 = 0;
7831 813 tempitem.misc6 = 0;
7832 813 tempitem.misc7 = 0;
7833 813 tempitem.misc8 = 0;
7834 813 tempitem.misc9 = 0;
7835 813 tempitem.misc10 = 0;
7836 813 tempitem.wpn4 = 0;
7837 813 tempitem.wpn5 = 0;
7838 813 tempitem.wpn6 = 0;
7839 813 tempitem.wpn7 = 0;
7840 813 tempitem.wpn8 = 0;
7841 813 tempitem.wpn9 = 0;
7842 813 tempitem.wpn10 = 0;
7843 813 break;
7844 }
7845 case itype_arrow:
7846 {
7847 801 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
7848 801 tempitem.misc2 = 0;
7849 801 tempitem.misc3 = 0;
7850 801 tempitem.misc4 = 0;
7851 801 tempitem.misc5 = 0;
7852 801 tempitem.misc6 = 0;
7853 801 tempitem.misc7 = 0;
7854 801 tempitem.misc8 = 0;
7855 801 tempitem.misc9 = 0;
7856 801 tempitem.misc10 = 0;
7857 801 tempitem.wpn4 = 0;
7858 801 tempitem.wpn5 = 0;
7859 801 tempitem.wpn6 = 0;
7860 801 tempitem.wpn7 = 0;
7861 801 tempitem.wpn8 = 0;
7862 801 tempitem.wpn9 = 0;
7863 801 tempitem.wpn10 = 0;
7864 801 break;
7865 }
7866 case itype_candle:
7867 {
7868 580 tempitem.flags &= ~ (item_flag3 | item_flag5);
7869 580 tempitem.misc1 = 0;
7870 580 tempitem.misc2 = 0;
7871 580 tempitem.misc3 = 0;
7872 580 tempitem.misc4 = 0;
7873 580 tempitem.misc5 = 0;
7874 580 tempitem.misc6 = 0;
7875 580 tempitem.misc7 = 0;
7876 580 tempitem.misc8 = 0;
7877 580 tempitem.misc9 = 0;
7878 580 tempitem.misc10 = 0;
7879 580 tempitem.wpn4 = 0;
7880 580 tempitem.wpn5 = 0;
7881 580 tempitem.wpn6 = 0;
7882 580 tempitem.wpn7 = 0;
7883 580 tempitem.wpn8 = 0;
7884 580 tempitem.wpn9 = 0;
7885 580 tempitem.wpn10 = 0;
7886 580 break;
7887 }
7888 case itype_whistle:
7889 {
7890 317 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
7891 317 tempitem.misc3 = 0;
7892 317 tempitem.misc4 = 0;
7893 317 tempitem.misc5 = 0;
7894 317 tempitem.misc6 = 0;
7895 317 tempitem.misc7 = 0;
7896 317 tempitem.misc8 = 0;
7897 317 tempitem.misc9 = 0;
7898 317 tempitem.misc10 = 0;
7899 317 tempitem.wpn2 = 0;
7900 317 tempitem.wpn3 = 0;
7901 317 tempitem.wpn4 = 0;
7902 317 tempitem.wpn5 = 0;
7903 317 tempitem.wpn6 = 0;
7904 317 tempitem.wpn7 = 0;
7905 317 tempitem.wpn8 = 0;
7906 317 tempitem.wpn9 = 0;
7907 317 tempitem.wpn10 = 0;
7908 317 break;
7909 }
7910 case itype_bait:
7911 {
7912 271 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7913 271 tempitem.misc2 = 0;
7914 271 tempitem.misc3 = 0;
7915 271 tempitem.misc4 = 0;
7916 271 tempitem.misc5 = 0;
7917 271 tempitem.misc6 = 0;
7918 271 tempitem.misc7 = 0;
7919 271 tempitem.misc8 = 0;
7920 271 tempitem.misc9 = 0;
7921 271 tempitem.misc10 = 0;
7922 271 tempitem.wpn2 = 0;
7923 271 tempitem.wpn3 = 0;
7924 271 tempitem.wpn4 = 0;
7925 271 tempitem.wpn5 = 0;
7926 271 tempitem.wpn6 = 0;
7927 271 tempitem.wpn7 = 0;
7928 271 tempitem.wpn8 = 0;
7929 271 tempitem.wpn9 = 0;
7930 271 tempitem.wpn10 = 0;
7931 271 break;
7932 }
7933 case itype_letter:
7934 {
7935 538 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7936 538 tempitem.misc1 = 0;
7937 538 tempitem.misc2 = 0;
7938 538 tempitem.misc3 = 0;
7939 538 tempitem.misc4 = 0;
7940 538 tempitem.misc5 = 0;
7941 538 tempitem.misc6 = 0;
7942 538 tempitem.misc7 = 0;
7943 538 tempitem.misc8 = 0;
7944 538 tempitem.misc9 = 0;
7945 538 tempitem.misc10 = 0;
7946 538 tempitem.wpn = 0;
7947 538 tempitem.wpn2 = 0;
7948 538 tempitem.wpn3 = 0;
7949 538 tempitem.wpn4 = 0;
7950 538 tempitem.wpn5 = 0;
7951 538 tempitem.wpn6 = 0;
7952 538 tempitem.wpn7 = 0;
7953 538 tempitem.wpn8 = 0;
7954 538 tempitem.wpn9 = 0;
7955 538 tempitem.wpn10 = 0;
7956 538 break;
7957 }
7958 case itype_potion:
7959 {
7960 593 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
7961 593 tempitem.misc3 = 0;
7962 593 tempitem.misc4 = 0;
7963 593 tempitem.misc5 = 0;
7964 593 tempitem.misc6 = 0;
7965 593 tempitem.misc7 = 0;
7966 593 tempitem.misc8 = 0;
7967 593 tempitem.misc9 = 0;
7968 593 tempitem.misc10 = 0;
7969 593 tempitem.wpn = 0;
7970 593 tempitem.wpn2 = 0;
7971 593 tempitem.wpn3 = 0;
7972 593 tempitem.wpn4 = 0;
7973 593 tempitem.wpn5 = 0;
7974 593 tempitem.wpn6 = 0;
7975 593 tempitem.wpn7 = 0;
7976 593 tempitem.wpn8 = 0;
7977 593 tempitem.wpn9 = 0;
7978 593 tempitem.wpn10 = 0;
7979 593 break;
7980 }
7981 case itype_wand:
7982 {
7983 287 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
7984 287 tempitem.misc1 = 0;
7985 287 tempitem.misc2 = 0;
7986 287 tempitem.misc3 = 0;
7987 287 tempitem.misc4 = 0;
7988 287 tempitem.misc5 = 0;
7989 287 tempitem.misc6 = 0;
7990 287 tempitem.misc7 = 0;
7991 287 tempitem.misc8 = 0;
7992 287 tempitem.misc9 = 0;
7993 287 tempitem.misc10 = 0;
7994 287 tempitem.wpn4 = 0;
7995 287 tempitem.wpn5 = 0;
7996 287 tempitem.wpn6 = 0;
7997 287 tempitem.wpn7 = 0;
7998 287 tempitem.wpn8 = 0;
7999 287 tempitem.wpn9 = 0;
8000 287 tempitem.wpn10 = 0;
8001 287 break;
8002 }
8003 case itype_ring:
8004 {
8005 861 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8006 861 tempitem.misc2 = 0;
8007 861 tempitem.misc3 = 0;
8008 861 tempitem.misc4 = 0;
8009 861 tempitem.misc5 = 0;
8010 861 tempitem.misc6 = 0;
8011 861 tempitem.misc7 = 0;
8012 861 tempitem.misc8 = 0;
8013 861 tempitem.misc9 = 0;
8014 861 tempitem.misc10 = 0;
8015 861 tempitem.wpn = 0;
8016 861 tempitem.wpn2 = 0;
8017 861 tempitem.wpn3 = 0;
8018 861 tempitem.wpn4 = 0;
8019 861 tempitem.wpn5 = 0;
8020 861 tempitem.wpn6 = 0;
8021 861 tempitem.wpn7 = 0;
8022 861 tempitem.wpn8 = 0;
8023 861 tempitem.wpn9 = 0;
8024 861 tempitem.wpn10 = 0;
8025 861 break;
8026 }
8027 case itype_wallet:
8028 {
8029 861 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8030 861 tempitem.misc3 = 0;
8031 861 tempitem.misc4 = 0;
8032 861 tempitem.misc5 = 0;
8033 861 tempitem.misc6 = 0;
8034 861 tempitem.misc7 = 0;
8035 861 tempitem.misc8 = 0;
8036 861 tempitem.misc9 = 0;
8037 861 tempitem.misc10 = 0;
8038 861 tempitem.wpn = 0;
8039 861 tempitem.wpn2 = 0;
8040 861 tempitem.wpn3 = 0;
8041 861 tempitem.wpn4 = 0;
8042 861 tempitem.wpn5 = 0;
8043 861 tempitem.wpn6 = 0;
8044 861 tempitem.wpn7 = 0;
8045 861 tempitem.wpn8 = 0;
8046 861 tempitem.wpn9 = 0;
8047 861 tempitem.wpn10 = 0;
8048 861 break;
8049 }
8050 case itype_amulet:
8051 {
8052 534 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8053 534 tempitem.misc1 = 0;
8054 534 tempitem.misc2 = 0;
8055 534 tempitem.misc3 = 0;
8056 534 tempitem.misc4 = 0;
8057 534 tempitem.misc5 = 0;
8058 534 tempitem.misc6 = 0;
8059 534 tempitem.misc7 = 0;
8060 534 tempitem.misc8 = 0;
8061 534 tempitem.misc9 = 0;
8062 534 tempitem.misc10 = 0;
8063 534 tempitem.wpn = 0;
8064 534 tempitem.wpn2 = 0;
8065 534 tempitem.wpn3 = 0;
8066 534 tempitem.wpn4 = 0;
8067 534 tempitem.wpn5 = 0;
8068 534 tempitem.wpn6 = 0;
8069 534 tempitem.wpn7 = 0;
8070 534 tempitem.wpn8 = 0;
8071 534 tempitem.wpn9 = 0;
8072 534 tempitem.wpn10 = 0;
8073 534 break;
8074 }
8075 case itype_shield:
8076 {
8077 821 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8078 821 tempitem.misc3 = 0;
8079 821 tempitem.misc4 = 0;
8080 821 tempitem.misc5 = 0;
8081 821 tempitem.misc6 = 0;
8082 821 tempitem.misc7 = 0;
8083 821 tempitem.misc8 = 0;
8084 821 tempitem.misc9 = 0;
8085 821 tempitem.misc10 = 0;
8086 821 tempitem.wpn = 0;
8087 821 tempitem.wpn2 = 0;
8088 821 tempitem.wpn3 = 0;
8089 821 tempitem.wpn4 = 0;
8090 821 tempitem.wpn5 = 0;
8091 821 tempitem.wpn6 = 0;
8092 821 tempitem.wpn7 = 0;
8093 821 tempitem.wpn8 = 0;
8094 821 tempitem.wpn9 = 0;
8095 821 tempitem.wpn10 = 0;
8096 821 break;
8097 }
8098 case itype_bow:
8099 {
8100 538 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8101 538 tempitem.misc1 = 0;
8102 538 tempitem.misc2 = 0;
8103 538 tempitem.misc3 = 0;
8104 538 tempitem.misc4 = 0;
8105 538 tempitem.misc5 = 0;
8106 538 tempitem.misc6 = 0;
8107 538 tempitem.misc7 = 0;
8108 538 tempitem.misc8 = 0;
8109 538 tempitem.misc9 = 0;
8110 538 tempitem.misc10 = 0;
8111 538 tempitem.wpn = 0;
8112 538 tempitem.wpn2 = 0;
8113 538 tempitem.wpn3 = 0;
8114 538 tempitem.wpn4 = 0;
8115 538 tempitem.wpn5 = 0;
8116 538 tempitem.wpn6 = 0;
8117 538 tempitem.wpn7 = 0;
8118 538 tempitem.wpn8 = 0;
8119 538 tempitem.wpn9 = 0;
8120 538 tempitem.wpn10 = 0;
8121 538 break;
8122 }
8123 case itype_raft:
8124 {
8125 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8126 269 tempitem.misc1 = 0;
8127 269 tempitem.misc2 = 0;
8128 269 tempitem.misc3 = 0;
8129 269 tempitem.misc4 = 0;
8130 269 tempitem.misc5 = 0;
8131 269 tempitem.misc6 = 0;
8132 269 tempitem.misc7 = 0;
8133 269 tempitem.misc8 = 0;
8134 269 tempitem.misc9 = 0;
8135 269 tempitem.misc10 = 0;
8136 269 tempitem.wpn = 0;
8137 269 tempitem.wpn2 = 0;
8138 269 tempitem.wpn3 = 0;
8139 269 tempitem.wpn4 = 0;
8140 269 tempitem.wpn5 = 0;
8141 269 tempitem.wpn6 = 0;
8142 269 tempitem.wpn7 = 0;
8143 269 tempitem.wpn8 = 0;
8144 269 tempitem.wpn9 = 0;
8145 269 tempitem.wpn10 = 0;
8146 269 break;
8147 }
8148 case itype_ladder:
8149 {
8150 538 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8151 538 tempitem.misc1 = 0;
8152 538 tempitem.misc2 = 0;
8153 538 tempitem.misc3 = 0;
8154 538 tempitem.misc4 = 0;
8155 538 tempitem.misc5 = 0;
8156 538 tempitem.misc6 = 0;
8157 538 tempitem.misc7 = 0;
8158 538 tempitem.misc8 = 0;
8159 538 tempitem.misc9 = 0;
8160 538 tempitem.misc10 = 0;
8161 538 tempitem.wpn = 0;
8162 538 tempitem.wpn2 = 0;
8163 538 tempitem.wpn3 = 0;
8164 538 tempitem.wpn4 = 0;
8165 538 tempitem.wpn5 = 0;
8166 538 tempitem.wpn6 = 0;
8167 538 tempitem.wpn7 = 0;
8168 538 tempitem.wpn8 = 0;
8169 538 tempitem.wpn9 = 0;
8170 538 tempitem.wpn10 = 0;
8171 538 break;
8172 }
8173 case itype_book:
8174 {
8175 285 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8176 285 tempitem.misc1 = 0;
8177 285 tempitem.misc2 = 0;
8178 285 tempitem.misc3 = 0;
8179 285 tempitem.misc4 = 0;
8180 285 tempitem.misc5 = 0;
8181 285 tempitem.misc6 = 0;
8182 285 tempitem.misc7 = 0;
8183 285 tempitem.misc8 = 0;
8184 285 tempitem.misc9 = 0;
8185 285 tempitem.misc10 = 0;
8186 285 tempitem.wpn3 = 0;
8187 285 tempitem.wpn4 = 0;
8188 285 tempitem.wpn5 = 0;
8189 285 tempitem.wpn6 = 0;
8190 285 tempitem.wpn7 = 0;
8191 285 tempitem.wpn8 = 0;
8192 285 tempitem.wpn9 = 0;
8193 285 tempitem.wpn10 = 0;
8194 285 break;
8195 }
8196 case itype_magickey:
8197 {
8198 269 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8199 269 tempitem.misc1 = 0;
8200 269 tempitem.misc2 = 0;
8201 269 tempitem.misc3 = 0;
8202 269 tempitem.misc4 = 0;
8203 269 tempitem.misc5 = 0;
8204 269 tempitem.misc6 = 0;
8205 269 tempitem.misc7 = 0;
8206 269 tempitem.misc8 = 0;
8207 269 tempitem.misc9 = 0;
8208 269 tempitem.misc10 = 0;
8209 269 tempitem.wpn = 0;
8210 269 tempitem.wpn2 = 0;
8211 269 tempitem.wpn3 = 0;
8212 269 tempitem.wpn4 = 0;
8213 269 tempitem.wpn5 = 0;
8214 269 tempitem.wpn6 = 0;
8215 269 tempitem.wpn7 = 0;
8216 269 tempitem.wpn8 = 0;
8217 269 tempitem.wpn9 = 0;
8218 269 tempitem.wpn10 = 0;
8219 269 break;
8220 }
8221 case itype_bracelet:
8222 {
8223 813 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8224 813 tempitem.misc1 = 0;
8225 813 tempitem.misc2 = 0;
8226 813 tempitem.misc3 = 0;
8227 813 tempitem.misc4 = 0;
8228 813 tempitem.misc5 = 0;
8229 813 tempitem.misc6 = 0;
8230 813 tempitem.misc7 = 0;
8231 813 tempitem.misc8 = 0;
8232 813 tempitem.misc9 = 0;
8233 813 tempitem.misc10 = 0;
8234 813 tempitem.wpn = 0;
8235 813 tempitem.wpn2 = 0;
8236 813 tempitem.wpn3 = 0;
8237 813 tempitem.wpn4 = 0;
8238 813 tempitem.wpn5 = 0;
8239 813 tempitem.wpn6 = 0;
8240 813 tempitem.wpn7 = 0;
8241 813 tempitem.wpn8 = 0;
8242 813 tempitem.wpn9 = 0;
8243 813 tempitem.wpn10 = 0;
8244 813 break;
8245 }
8246 case itype_flippers:
8247 {
8248 271 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8249 271 tempitem.misc1 = 0;
8250 271 tempitem.misc2 = 0;
8251 271 tempitem.misc3 = 0;
8252 271 tempitem.misc4 = 0;
8253 271 tempitem.misc5 = 0;
8254 271 tempitem.misc6 = 0;
8255 271 tempitem.misc7 = 0;
8256 271 tempitem.misc8 = 0;
8257 271 tempitem.misc9 = 0;
8258 271 tempitem.misc10 = 0;
8259 271 tempitem.wpn = 0;
8260 271 tempitem.wpn2 = 0;
8261 271 tempitem.wpn3 = 0;
8262 271 tempitem.wpn4 = 0;
8263 271 tempitem.wpn5 = 0;
8264 271 tempitem.wpn6 = 0;
8265 271 tempitem.wpn7 = 0;
8266 271 tempitem.wpn8 = 0;
8267 271 tempitem.wpn9 = 0;
8268 271 tempitem.wpn10 = 0;
8269 271 break;
8270 }
8271 case itype_boots:
8272 {
8273 273 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8274 273 tempitem.misc1 = 0;
8275 273 tempitem.misc2 = 0;
8276 273 tempitem.misc3 = 0;
8277 273 tempitem.misc4 = 0;
8278 273 tempitem.misc5 = 0;
8279 273 tempitem.misc6 = 0;
8280 273 tempitem.misc7 = 0;
8281 273 tempitem.misc8 = 0;
8282 273 tempitem.misc9 = 0;
8283 273 tempitem.misc10 = 0;
8284 273 tempitem.wpn = 0;
8285 273 tempitem.wpn2 = 0;
8286 273 tempitem.wpn3 = 0;
8287 273 tempitem.wpn4 = 0;
8288 273 tempitem.wpn5 = 0;
8289 273 tempitem.wpn6 = 0;
8290 273 tempitem.wpn7 = 0;
8291 273 tempitem.wpn8 = 0;
8292 273 tempitem.wpn9 = 0;
8293 273 tempitem.wpn10 = 0;
8294 273 break;
8295 }
8296 case itype_hookshot:
8297 {
8298 540 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8299 540 tempitem.misc5 = 0;
8300 540 tempitem.misc6 = 0;
8301 540 tempitem.misc7 = 0;
8302 540 tempitem.misc8 = 0;
8303 540 tempitem.misc9 = 0;
8304 540 tempitem.misc10 = 0;
8305 540 tempitem.wpn5 = 0;
8306 540 tempitem.wpn6 = 0;
8307 540 tempitem.wpn7 = 0;
8308 540 tempitem.wpn8 = 0;
8309 540 tempitem.wpn9 = 0;
8310 540 tempitem.wpn10 = 0;
8311 540 break;
8312 }
8313 case itype_lens:
8314 {
8315 245 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8316 245 tempitem.misc2 = 0;
8317 245 tempitem.misc3 = 0;
8318 245 tempitem.misc4 = 0;
8319 245 tempitem.misc5 = 0;
8320 245 tempitem.misc6 = 0;
8321 245 tempitem.misc7 = 0;
8322 245 tempitem.misc8 = 0;
8323 245 tempitem.misc9 = 0;
8324 245 tempitem.misc10 = 0;
8325 245 tempitem.wpn = 0;
8326 245 tempitem.wpn2 = 0;
8327 245 tempitem.wpn3 = 0;
8328 245 tempitem.wpn4 = 0;
8329 245 tempitem.wpn5 = 0;
8330 245 tempitem.wpn6 = 0;
8331 245 tempitem.wpn7 = 0;
8332 245 tempitem.wpn8 = 0;
8333 245 tempitem.wpn9 = 0;
8334 245 tempitem.wpn10 = 0;
8335 245 break;
8336 }
8337 case itype_hammer:
8338 {
8339 271 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8340 271 tempitem.misc1 = 0;
8341 271 tempitem.misc2 = 0;
8342 271 tempitem.misc3 = 0;
8343 271 tempitem.misc4 = 0;
8344 271 tempitem.misc5 = 0;
8345 271 tempitem.misc6 = 0;
8346 271 tempitem.misc7 = 0;
8347 271 tempitem.misc8 = 0;
8348 271 tempitem.misc9 = 0;
8349 271 tempitem.misc10 = 0;
8350 271 tempitem.wpn3 = 0;
8351 271 tempitem.wpn4 = 0;
8352 271 tempitem.wpn5 = 0;
8353 271 tempitem.wpn6 = 0;
8354 271 tempitem.wpn7 = 0;
8355 271 tempitem.wpn8 = 0;
8356 271 tempitem.wpn9 = 0;
8357 271 tempitem.wpn10 = 0;
8358 271 break;
8359 }
8360 case itype_divinefire:
8361 {
8362 269 tempitem.flags &= ~ (item_flag1 | item_flag4 | item_flag5);
8363 269 tempitem.misc3 = 0;
8364 269 tempitem.misc4 = 0;
8365 269 tempitem.misc5 = 0;
8366 269 tempitem.misc6 = 0;
8367 269 tempitem.misc7 = 0;
8368 269 tempitem.misc8 = 0;
8369 269 tempitem.misc9 = 0;
8370 269 tempitem.misc10 = 0;
8371 269 tempitem.wpn6 = 0;
8372 269 tempitem.wpn7 = 0;
8373 269 tempitem.wpn8 = 0;
8374 269 tempitem.wpn9 = 0;
8375 269 tempitem.wpn10 = 0;
8376 269 break;
8377 }
8378 case itype_divineescape:
8379 {
8380 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8381 269 tempitem.misc2 = 0;
8382 269 tempitem.misc3 = 0;
8383 269 tempitem.misc4 = 0;
8384 269 tempitem.misc5 = 0;
8385 269 tempitem.misc6 = 0;
8386 269 tempitem.misc7 = 0;
8387 269 tempitem.misc8 = 0;
8388 269 tempitem.misc9 = 0;
8389 269 tempitem.misc10 = 0;
8390 269 tempitem.wpn = 0;
8391 269 tempitem.wpn2 = 0;
8392 269 tempitem.wpn3 = 0;
8393 269 tempitem.wpn4 = 0;
8394 269 tempitem.wpn5 = 0;
8395 269 tempitem.wpn6 = 0;
8396 269 tempitem.wpn7 = 0;
8397 269 tempitem.wpn8 = 0;
8398 269 tempitem.wpn9 = 0;
8399 269 tempitem.wpn10 = 0;
8400 269 break;
8401 }
8402 case itype_divineprotection:
8403 {
8404 269 tempitem.flags &= ~ (item_flag5);
8405 269 tempitem.misc2 = 0;
8406 269 tempitem.misc3 = 0;
8407 269 tempitem.misc4 = 0;
8408 269 tempitem.misc5 = 0;
8409 269 tempitem.misc6 = 0;
8410 269 tempitem.misc7 = 0;
8411 269 tempitem.misc8 = 0;
8412 269 tempitem.misc9 = 0;
8413 269 tempitem.misc10 = 0;
8414 269 break;
8415 }
8416 case itype_bomb:
8417 {
8418 285 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8419 285 tempitem.misc4 = 0;
8420 285 tempitem.misc5 = 0;
8421 285 tempitem.misc6 = 0;
8422 285 tempitem.misc7 = 0;
8423 285 tempitem.misc8 = 0;
8424 285 tempitem.misc9 = 0;
8425 285 tempitem.misc10 = 0;
8426 285 tempitem.wpn3 = 0;
8427 285 tempitem.wpn4 = 0;
8428 285 tempitem.wpn5 = 0;
8429 285 tempitem.wpn6 = 0;
8430 285 tempitem.wpn7 = 0;
8431 285 tempitem.wpn8 = 0;
8432 285 tempitem.wpn9 = 0;
8433 285 tempitem.wpn10 = 0;
8434 285 break;
8435 }
8436 case itype_sbomb:
8437 {
8438 271 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8439 271 tempitem.misc4 = 0;
8440 271 tempitem.misc5 = 0;
8441 271 tempitem.misc6 = 0;
8442 271 tempitem.misc7 = 0;
8443 271 tempitem.misc8 = 0;
8444 271 tempitem.misc9 = 0;
8445 271 tempitem.misc10 = 0;
8446 271 tempitem.wpn3 = 0;
8447 271 tempitem.wpn4 = 0;
8448 271 tempitem.wpn5 = 0;
8449 271 tempitem.wpn6 = 0;
8450 271 tempitem.wpn7 = 0;
8451 271 tempitem.wpn8 = 0;
8452 271 tempitem.wpn9 = 0;
8453 271 tempitem.wpn10 = 0;
8454 271 break;
8455 }
8456 case itype_clock:
8457 {
8458 271 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8459 271 tempitem.misc2 = 0;
8460 271 tempitem.misc3 = 0;
8461 271 tempitem.misc4 = 0;
8462 271 tempitem.misc5 = 0;
8463 271 tempitem.misc6 = 0;
8464 271 tempitem.misc7 = 0;
8465 271 tempitem.misc8 = 0;
8466 271 tempitem.misc9 = 0;
8467 271 tempitem.misc10 = 0;
8468 271 tempitem.wpn = 0;
8469 271 tempitem.wpn2 = 0;
8470 271 tempitem.wpn3 = 0;
8471 271 tempitem.wpn4 = 0;
8472 271 tempitem.wpn5 = 0;
8473 271 tempitem.wpn6 = 0;
8474 271 tempitem.wpn7 = 0;
8475 271 tempitem.wpn8 = 0;
8476 271 tempitem.wpn9 = 0;
8477 271 tempitem.wpn10 = 0;
8478 271 break;
8479 }
8480 case itype_key:
8481 {
8482 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8483 269 tempitem.misc1 = 0;
8484 269 tempitem.misc2 = 0;
8485 269 tempitem.misc3 = 0;
8486 269 tempitem.misc4 = 0;
8487 269 tempitem.misc5 = 0;
8488 269 tempitem.misc6 = 0;
8489 269 tempitem.misc7 = 0;
8490 269 tempitem.misc8 = 0;
8491 269 tempitem.misc9 = 0;
8492 269 tempitem.misc10 = 0;
8493 269 tempitem.wpn = 0;
8494 269 tempitem.wpn2 = 0;
8495 269 tempitem.wpn3 = 0;
8496 269 tempitem.wpn4 = 0;
8497 269 tempitem.wpn5 = 0;
8498 269 tempitem.wpn6 = 0;
8499 269 tempitem.wpn7 = 0;
8500 269 tempitem.wpn8 = 0;
8501 269 tempitem.wpn9 = 0;
8502 269 tempitem.wpn10 = 0;
8503 269 break;
8504 }
8505 case itype_magiccontainer:
8506 {
8507 273 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8508 273 tempitem.misc1 = 0;
8509 273 tempitem.misc2 = 0;
8510 273 tempitem.misc3 = 0;
8511 273 tempitem.misc4 = 0;
8512 273 tempitem.misc5 = 0;
8513 273 tempitem.misc6 = 0;
8514 273 tempitem.misc7 = 0;
8515 273 tempitem.misc8 = 0;
8516 273 tempitem.misc9 = 0;
8517 273 tempitem.misc10 = 0;
8518 273 tempitem.wpn = 0;
8519 273 tempitem.wpn2 = 0;
8520 273 tempitem.wpn3 = 0;
8521 273 tempitem.wpn4 = 0;
8522 273 tempitem.wpn5 = 0;
8523 273 tempitem.wpn6 = 0;
8524 273 tempitem.wpn7 = 0;
8525 273 tempitem.wpn8 = 0;
8526 273 tempitem.wpn9 = 0;
8527 273 tempitem.wpn10 = 0;
8528 273 break;
8529 }
8530 case itype_triforcepiece:
8531 {
8532 538 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8533 538 tempitem.misc3 = 0;
8534 538 tempitem.misc4 = 0;
8535 538 tempitem.misc5 = 0;
8536 538 tempitem.misc6 = 0;
8537 538 tempitem.misc7 = 0;
8538 538 tempitem.misc8 = 0;
8539 538 tempitem.misc9 = 0;
8540 538 tempitem.misc10 = 0;
8541 538 tempitem.wpn = 0;
8542 538 tempitem.wpn2 = 0;
8543 538 tempitem.wpn3 = 0;
8544 538 tempitem.wpn4 = 0;
8545 538 tempitem.wpn5 = 0;
8546 538 tempitem.wpn6 = 0;
8547 538 tempitem.wpn7 = 0;
8548 538 tempitem.wpn8 = 0;
8549 538 tempitem.wpn9 = 0;
8550 538 tempitem.wpn10 = 0;
8551 538 break;
8552 }
8553 case itype_map: case itype_compass: case itype_bosskey:
8554 {
8555 811 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8556 811 tempitem.misc1 = 0;
8557 811 tempitem.misc2 = 0;
8558 811 tempitem.misc3 = 0;
8559 811 tempitem.misc4 = 0;
8560 811 tempitem.misc5 = 0;
8561 811 tempitem.misc6 = 0;
8562 811 tempitem.misc7 = 0;
8563 811 tempitem.misc8 = 0;
8564 811 tempitem.misc9 = 0;
8565 811 tempitem.misc10 = 0;
8566 811 tempitem.wpn = 0;
8567 811 tempitem.wpn2 = 0;
8568 811 tempitem.wpn3 = 0;
8569 811 tempitem.wpn4 = 0;
8570 811 tempitem.wpn5 = 0;
8571 811 tempitem.wpn6 = 0;
8572 811 tempitem.wpn7 = 0;
8573 811 tempitem.wpn8 = 0;
8574 811 tempitem.wpn9 = 0;
8575 811 tempitem.wpn10 = 0;
8576 811 break;
8577 }
8578 case itype_quiver:
8579 {
8580 1076 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8581 1076 tempitem.misc3 = 0;
8582 1076 tempitem.misc4 = 0;
8583 1076 tempitem.misc5 = 0;
8584 1076 tempitem.misc6 = 0;
8585 1076 tempitem.misc7 = 0;
8586 1076 tempitem.misc8 = 0;
8587 1076 tempitem.misc9 = 0;
8588 1076 tempitem.misc10 = 0;
8589 1076 tempitem.wpn = 0;
8590 1076 tempitem.wpn2 = 0;
8591 1076 tempitem.wpn3 = 0;
8592 1076 tempitem.wpn4 = 0;
8593 1076 tempitem.wpn5 = 0;
8594 1076 tempitem.wpn6 = 0;
8595 1076 tempitem.wpn7 = 0;
8596 1076 tempitem.wpn8 = 0;
8597 1076 tempitem.wpn9 = 0;
8598 1076 tempitem.wpn10 = 0;
8599 1076 break;
8600 }
8601 case itype_lkey:
8602 {
8603 759 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8604 759 tempitem.misc1 = 0;
8605 759 tempitem.misc2 = 0;
8606 759 tempitem.misc3 = 0;
8607 759 tempitem.misc4 = 0;
8608 759 tempitem.misc5 = 0;
8609 759 tempitem.misc6 = 0;
8610 759 tempitem.misc7 = 0;
8611 759 tempitem.misc8 = 0;
8612 759 tempitem.misc9 = 0;
8613 759 tempitem.misc10 = 0;
8614 759 tempitem.wpn = 0;
8615 759 tempitem.wpn2 = 0;
8616 759 tempitem.wpn3 = 0;
8617 759 tempitem.wpn4 = 0;
8618 759 tempitem.wpn5 = 0;
8619 759 tempitem.wpn6 = 0;
8620 759 tempitem.wpn7 = 0;
8621 759 tempitem.wpn8 = 0;
8622 759 tempitem.wpn9 = 0;
8623 759 tempitem.wpn10 = 0;
8624 759 break;
8625 }
8626 case itype_cbyrna:
8627 {
8628 269 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
8629 269 tempitem.misc4 = 0;
8630 269 tempitem.misc5 = 0;
8631 269 tempitem.misc6 = 0;
8632 269 tempitem.misc7 = 0;
8633 269 tempitem.misc8 = 0;
8634 269 tempitem.misc9 = 0;
8635 269 tempitem.misc10 = 0;
8636 269 tempitem.wpn6 = 0;
8637 269 tempitem.wpn7 = 0;
8638 269 tempitem.wpn8 = 0;
8639 269 tempitem.wpn9 = 0;
8640 269 tempitem.wpn10 = 0;
8641 269 break;
8642 }
8643 case itype_rupee: case itype_arrowammo:
8644 {
8645 3150 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8646 3150 tempitem.misc1 = 0;
8647 3150 tempitem.misc2 = 0;
8648 3150 tempitem.misc3 = 0;
8649 3150 tempitem.misc4 = 0;
8650 3150 tempitem.misc5 = 0;
8651 3150 tempitem.misc6 = 0;
8652 3150 tempitem.misc7 = 0;
8653 3150 tempitem.misc8 = 0;
8654 3150 tempitem.misc9 = 0;
8655 3150 tempitem.misc10 = 0;
8656 3150 tempitem.wpn = 0;
8657 3150 tempitem.wpn2 = 0;
8658 3150 tempitem.wpn3 = 0;
8659 3150 tempitem.wpn4 = 0;
8660 3150 tempitem.wpn5 = 0;
8661 3150 tempitem.wpn6 = 0;
8662 3150 tempitem.wpn7 = 0;
8663 3150 tempitem.wpn8 = 0;
8664 3150 tempitem.wpn9 = 0;
8665 3150 tempitem.wpn10 = 0;
8666 3150 break;
8667 }
8668 case itype_fairy:
8669 {
8670 523 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
8671 523 tempitem.misc4 = 0;
8672 523 tempitem.misc5 = 0;
8673 523 tempitem.misc6 = 0;
8674 523 tempitem.misc7 = 0;
8675 523 tempitem.misc8 = 0;
8676 523 tempitem.misc9 = 0;
8677 523 tempitem.misc10 = 0;
8678 523 tempitem.wpn = 0;
8679 523 tempitem.wpn2 = 0;
8680 523 tempitem.wpn3 = 0;
8681 523 tempitem.wpn4 = 0;
8682 523 tempitem.wpn5 = 0;
8683 523 tempitem.wpn6 = 0;
8684 523 tempitem.wpn7 = 0;
8685 523 tempitem.wpn8 = 0;
8686 523 tempitem.wpn9 = 0;
8687 523 tempitem.wpn10 = 0;
8688 523 break;
8689 }
8690 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8691 {
8692 2766 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8693 2766 tempitem.misc1 = 0;
8694 2766 tempitem.misc2 = 0;
8695 2766 tempitem.misc3 = 0;
8696 2766 tempitem.misc4 = 0;
8697 2766 tempitem.misc5 = 0;
8698 2766 tempitem.misc6 = 0;
8699 2766 tempitem.misc7 = 0;
8700 2766 tempitem.misc8 = 0;
8701 2766 tempitem.misc9 = 0;
8702 2766 tempitem.misc10 = 0;
8703 2766 tempitem.wpn = 0;
8704 2766 tempitem.wpn2 = 0;
8705 2766 tempitem.wpn3 = 0;
8706 2766 tempitem.wpn4 = 0;
8707 2766 tempitem.wpn5 = 0;
8708 2766 tempitem.wpn6 = 0;
8709 2766 tempitem.wpn7 = 0;
8710 2766 tempitem.wpn8 = 0;
8711 2766 tempitem.wpn9 = 0;
8712 2766 tempitem.wpn10 = 0;
8713 2766 break;
8714 }
8715 case itype_bombbag:
8716 {
8717 1076 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8718 1076 tempitem.misc3 = 0;
8719 1076 tempitem.misc4 = 0;
8720 1076 tempitem.misc5 = 0;
8721 1076 tempitem.misc6 = 0;
8722 1076 tempitem.misc7 = 0;
8723 1076 tempitem.misc8 = 0;
8724 1076 tempitem.misc9 = 0;
8725 1076 tempitem.misc10 = 0;
8726 1076 tempitem.wpn = 0;
8727 1076 tempitem.wpn2 = 0;
8728 1076 tempitem.wpn3 = 0;
8729 1076 tempitem.wpn4 = 0;
8730 1076 tempitem.wpn5 = 0;
8731 1076 tempitem.wpn6 = 0;
8732 1076 tempitem.wpn7 = 0;
8733 1076 tempitem.wpn8 = 0;
8734 1076 tempitem.wpn9 = 0;
8735 1076 tempitem.wpn10 = 0;
8736 1076 break;
8737 }
8738 case itype_rocs:
8739 {
8740 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8741 269 tempitem.misc1 = 0;
8742 269 tempitem.misc2 = 0;
8743 269 tempitem.misc3 = 0;
8744 269 tempitem.misc4 = 0;
8745 269 tempitem.misc5 = 0;
8746 269 tempitem.misc6 = 0;
8747 269 tempitem.misc7 = 0;
8748 269 tempitem.misc8 = 0;
8749 269 tempitem.misc9 = 0;
8750 269 tempitem.misc10 = 0;
8751 269 tempitem.wpn = 0;
8752 269 tempitem.wpn2 = 0;
8753 269 tempitem.wpn3 = 0;
8754 269 tempitem.wpn4 = 0;
8755 269 tempitem.wpn5 = 0;
8756 269 tempitem.wpn6 = 0;
8757 269 tempitem.wpn7 = 0;
8758 269 tempitem.wpn8 = 0;
8759 269 tempitem.wpn9 = 0;
8760 269 tempitem.wpn10 = 0;
8761 269 break;
8762 }
8763 case itype_hoverboots:
8764 {
8765 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8766 269 tempitem.misc2 = 0;
8767 269 tempitem.misc3 = 0;
8768 269 tempitem.misc4 = 0;
8769 269 tempitem.misc5 = 0;
8770 269 tempitem.misc6 = 0;
8771 269 tempitem.misc7 = 0;
8772 269 tempitem.misc8 = 0;
8773 269 tempitem.misc9 = 0;
8774 269 tempitem.misc10 = 0;
8775 269 tempitem.wpn2 = 0;
8776 269 tempitem.wpn3 = 0;
8777 269 tempitem.wpn4 = 0;
8778 269 tempitem.wpn5 = 0;
8779 269 tempitem.wpn6 = 0;
8780 269 tempitem.wpn7 = 0;
8781 269 tempitem.wpn8 = 0;
8782 269 tempitem.wpn9 = 0;
8783 269 tempitem.wpn10 = 0;
8784 269 break;
8785 }
8786 case itype_spinscroll:
8787 {
8788 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8789 269 tempitem.misc2 = 0;
8790 269 tempitem.misc3 = 0;
8791 269 tempitem.misc4 = 0;
8792 269 tempitem.misc5 = 0;
8793 269 tempitem.misc6 = 0;
8794 269 tempitem.misc7 = 0;
8795 269 tempitem.misc8 = 0;
8796 269 tempitem.misc9 = 0;
8797 269 tempitem.misc10 = 0;
8798 269 tempitem.wpn = 0;
8799 269 tempitem.wpn2 = 0;
8800 269 tempitem.wpn3 = 0;
8801 269 tempitem.wpn4 = 0;
8802 269 tempitem.wpn5 = 0;
8803 269 tempitem.wpn6 = 0;
8804 269 tempitem.wpn7 = 0;
8805 269 tempitem.wpn8 = 0;
8806 269 tempitem.wpn9 = 0;
8807 269 tempitem.wpn10 = 0;
8808 269 break;
8809 }
8810 case itype_crossscroll:
8811 {
8812 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8813 269 tempitem.misc1 = 0;
8814 269 tempitem.misc2 = 0;
8815 269 tempitem.misc3 = 0;
8816 269 tempitem.misc4 = 0;
8817 269 tempitem.misc5 = 0;
8818 269 tempitem.misc6 = 0;
8819 269 tempitem.misc7 = 0;
8820 269 tempitem.misc8 = 0;
8821 269 tempitem.misc9 = 0;
8822 269 tempitem.misc10 = 0;
8823 269 tempitem.wpn = 0;
8824 269 tempitem.wpn2 = 0;
8825 269 tempitem.wpn3 = 0;
8826 269 tempitem.wpn4 = 0;
8827 269 tempitem.wpn5 = 0;
8828 269 tempitem.wpn6 = 0;
8829 269 tempitem.wpn7 = 0;
8830 269 tempitem.wpn8 = 0;
8831 269 tempitem.wpn9 = 0;
8832 269 tempitem.wpn10 = 0;
8833 269 break;
8834 }
8835 case itype_quakescroll:
8836 {
8837 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8838 269 tempitem.misc3 = 0;
8839 269 tempitem.misc4 = 0;
8840 269 tempitem.misc5 = 0;
8841 269 tempitem.misc6 = 0;
8842 269 tempitem.misc7 = 0;
8843 269 tempitem.misc8 = 0;
8844 269 tempitem.misc9 = 0;
8845 269 tempitem.misc10 = 0;
8846 269 tempitem.wpn = 0;
8847 269 tempitem.wpn2 = 0;
8848 269 tempitem.wpn3 = 0;
8849 269 tempitem.wpn4 = 0;
8850 269 tempitem.wpn5 = 0;
8851 269 tempitem.wpn6 = 0;
8852 269 tempitem.wpn7 = 0;
8853 269 tempitem.wpn8 = 0;
8854 269 tempitem.wpn9 = 0;
8855 269 tempitem.wpn10 = 0;
8856 269 break;
8857 }
8858 case itype_whispring:
8859 {
8860 540 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8861 540 tempitem.misc2 = 0;
8862 540 tempitem.misc3 = 0;
8863 540 tempitem.misc4 = 0;
8864 540 tempitem.misc5 = 0;
8865 540 tempitem.misc6 = 0;
8866 540 tempitem.misc7 = 0;
8867 540 tempitem.misc8 = 0;
8868 540 tempitem.misc9 = 0;
8869 540 tempitem.misc10 = 0;
8870 540 tempitem.wpn = 0;
8871 540 tempitem.wpn2 = 0;
8872 540 tempitem.wpn3 = 0;
8873 540 tempitem.wpn4 = 0;
8874 540 tempitem.wpn5 = 0;
8875 540 tempitem.wpn6 = 0;
8876 540 tempitem.wpn7 = 0;
8877 540 tempitem.wpn8 = 0;
8878 540 tempitem.wpn9 = 0;
8879 540 tempitem.wpn10 = 0;
8880 540 break;
8881 }
8882 case itype_chargering:
8883 {
8884 538 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8885 538 tempitem.misc3 = 0;
8886 538 tempitem.misc4 = 0;
8887 538 tempitem.misc5 = 0;
8888 538 tempitem.misc6 = 0;
8889 538 tempitem.misc7 = 0;
8890 538 tempitem.misc8 = 0;
8891 538 tempitem.misc9 = 0;
8892 538 tempitem.misc10 = 0;
8893 538 tempitem.wpn = 0;
8894 538 tempitem.wpn2 = 0;
8895 538 tempitem.wpn3 = 0;
8896 538 tempitem.wpn4 = 0;
8897 538 tempitem.wpn5 = 0;
8898 538 tempitem.wpn6 = 0;
8899 538 tempitem.wpn7 = 0;
8900 538 tempitem.wpn8 = 0;
8901 538 tempitem.wpn9 = 0;
8902 538 tempitem.wpn10 = 0;
8903 538 break;
8904 }
8905 case itype_perilscroll:
8906 {
8907 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8908 269 tempitem.misc2 = 0;
8909 269 tempitem.misc3 = 0;
8910 269 tempitem.misc4 = 0;
8911 269 tempitem.misc5 = 0;
8912 269 tempitem.misc6 = 0;
8913 269 tempitem.misc7 = 0;
8914 269 tempitem.misc8 = 0;
8915 269 tempitem.misc9 = 0;
8916 269 tempitem.misc10 = 0;
8917 269 tempitem.wpn = 0;
8918 269 tempitem.wpn2 = 0;
8919 269 tempitem.wpn3 = 0;
8920 269 tempitem.wpn4 = 0;
8921 269 tempitem.wpn5 = 0;
8922 269 tempitem.wpn6 = 0;
8923 269 tempitem.wpn7 = 0;
8924 269 tempitem.wpn8 = 0;
8925 269 tempitem.wpn9 = 0;
8926 269 tempitem.wpn10 = 0;
8927 269 break;
8928 }
8929 case itype_wealthmedal:
8930 {
8931 809 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8932 809 tempitem.misc2 = 0;
8933 809 tempitem.misc3 = 0;
8934 809 tempitem.misc4 = 0;
8935 809 tempitem.misc5 = 0;
8936 809 tempitem.misc6 = 0;
8937 809 tempitem.misc7 = 0;
8938 809 tempitem.misc8 = 0;
8939 809 tempitem.misc9 = 0;
8940 809 tempitem.misc10 = 0;
8941 809 tempitem.wpn = 0;
8942 809 tempitem.wpn2 = 0;
8943 809 tempitem.wpn3 = 0;
8944 809 tempitem.wpn4 = 0;
8945 809 tempitem.wpn5 = 0;
8946 809 tempitem.wpn6 = 0;
8947 809 tempitem.wpn7 = 0;
8948 809 tempitem.wpn8 = 0;
8949 809 tempitem.wpn9 = 0;
8950 809 tempitem.wpn10 = 0;
8951 809 break;
8952 }
8953 case itype_heartring:
8954 {
8955 811 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8956 811 tempitem.misc3 = 0;
8957 811 tempitem.misc4 = 0;
8958 811 tempitem.misc5 = 0;
8959 811 tempitem.misc6 = 0;
8960 811 tempitem.misc7 = 0;
8961 811 tempitem.misc8 = 0;
8962 811 tempitem.misc9 = 0;
8963 811 tempitem.misc10 = 0;
8964 811 tempitem.wpn = 0;
8965 811 tempitem.wpn2 = 0;
8966 811 tempitem.wpn3 = 0;
8967 811 tempitem.wpn4 = 0;
8968 811 tempitem.wpn5 = 0;
8969 811 tempitem.wpn6 = 0;
8970 811 tempitem.wpn7 = 0;
8971 811 tempitem.wpn8 = 0;
8972 811 tempitem.wpn9 = 0;
8973 811 tempitem.wpn10 = 0;
8974 811 break;
8975 }
8976 case itype_magicring:
8977 {
8978 1084 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8979 1084 tempitem.misc3 = 0;
8980 1084 tempitem.misc4 = 0;
8981 1084 tempitem.misc5 = 0;
8982 1084 tempitem.misc6 = 0;
8983 1084 tempitem.misc7 = 0;
8984 1084 tempitem.misc8 = 0;
8985 1084 tempitem.misc9 = 0;
8986 1084 tempitem.misc10 = 0;
8987 1084 tempitem.wpn = 0;
8988 1084 tempitem.wpn2 = 0;
8989 1084 tempitem.wpn3 = 0;
8990 1084 tempitem.wpn4 = 0;
8991 1084 tempitem.wpn5 = 0;
8992 1084 tempitem.wpn6 = 0;
8993 1084 tempitem.wpn7 = 0;
8994 1084 tempitem.wpn8 = 0;
8995 1084 tempitem.wpn9 = 0;
8996 1084 tempitem.wpn10 = 0;
8997 1084 break;
8998 }
8999 case itype_spinscroll2:
9000 {
9001 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9002 269 tempitem.misc2 = 0;
9003 269 tempitem.misc3 = 0;
9004 269 tempitem.misc4 = 0;
9005 269 tempitem.misc5 = 0;
9006 269 tempitem.misc6 = 0;
9007 269 tempitem.misc7 = 0;
9008 269 tempitem.misc8 = 0;
9009 269 tempitem.misc9 = 0;
9010 269 tempitem.misc10 = 0;
9011 269 tempitem.wpn = 0;
9012 269 tempitem.wpn2 = 0;
9013 269 tempitem.wpn3 = 0;
9014 269 tempitem.wpn4 = 0;
9015 269 tempitem.wpn5 = 0;
9016 269 tempitem.wpn6 = 0;
9017 269 tempitem.wpn7 = 0;
9018 269 tempitem.wpn8 = 0;
9019 269 tempitem.wpn9 = 0;
9020 269 tempitem.wpn10 = 0;
9021 269 break;
9022 }
9023 case itype_quakescroll2:
9024 {
9025 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9026 269 tempitem.misc3 = 0;
9027 269 tempitem.misc4 = 0;
9028 269 tempitem.misc5 = 0;
9029 269 tempitem.misc6 = 0;
9030 269 tempitem.misc7 = 0;
9031 269 tempitem.misc8 = 0;
9032 269 tempitem.misc9 = 0;
9033 269 tempitem.misc10 = 0;
9034 269 tempitem.wpn = 0;
9035 269 tempitem.wpn2 = 0;
9036 269 tempitem.wpn3 = 0;
9037 269 tempitem.wpn4 = 0;
9038 269 tempitem.wpn5 = 0;
9039 269 tempitem.wpn6 = 0;
9040 269 tempitem.wpn7 = 0;
9041 269 tempitem.wpn8 = 0;
9042 269 tempitem.wpn9 = 0;
9043 269 tempitem.wpn10 = 0;
9044 269 break;
9045 }
9046 case itype_agony:
9047 {
9048 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9049 269 tempitem.misc2 = 0;
9050 269 tempitem.misc3 = 0;
9051 269 tempitem.misc4 = 0;
9052 269 tempitem.misc5 = 0;
9053 269 tempitem.misc6 = 0;
9054 269 tempitem.misc7 = 0;
9055 269 tempitem.misc8 = 0;
9056 269 tempitem.misc9 = 0;
9057 269 tempitem.misc10 = 0;
9058 269 tempitem.wpn = 0;
9059 269 tempitem.wpn2 = 0;
9060 269 tempitem.wpn3 = 0;
9061 269 tempitem.wpn4 = 0;
9062 269 tempitem.wpn5 = 0;
9063 269 tempitem.wpn6 = 0;
9064 269 tempitem.wpn7 = 0;
9065 269 tempitem.wpn8 = 0;
9066 269 tempitem.wpn9 = 0;
9067 269 tempitem.wpn10 = 0;
9068 269 break;
9069 }
9070 case itype_stompboots:
9071 {
9072 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9073 269 tempitem.misc1 = 0;
9074 269 tempitem.misc2 = 0;
9075 269 tempitem.misc3 = 0;
9076 269 tempitem.misc4 = 0;
9077 269 tempitem.misc5 = 0;
9078 269 tempitem.misc6 = 0;
9079 269 tempitem.misc7 = 0;
9080 269 tempitem.misc8 = 0;
9081 269 tempitem.misc9 = 0;
9082 269 tempitem.misc10 = 0;
9083 269 tempitem.wpn = 0;
9084 269 tempitem.wpn2 = 0;
9085 269 tempitem.wpn3 = 0;
9086 269 tempitem.wpn4 = 0;
9087 269 tempitem.wpn5 = 0;
9088 269 tempitem.wpn6 = 0;
9089 269 tempitem.wpn7 = 0;
9090 269 tempitem.wpn8 = 0;
9091 269 tempitem.wpn9 = 0;
9092 269 tempitem.wpn10 = 0;
9093 269 break;
9094 }
9095 case itype_whimsicalring:
9096 {
9097 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9098 269 tempitem.misc2 = 0;
9099 269 tempitem.misc3 = 0;
9100 269 tempitem.misc4 = 0;
9101 269 tempitem.misc5 = 0;
9102 269 tempitem.misc6 = 0;
9103 269 tempitem.misc7 = 0;
9104 269 tempitem.misc8 = 0;
9105 269 tempitem.misc9 = 0;
9106 269 tempitem.misc10 = 0;
9107 269 tempitem.wpn = 0;
9108 269 tempitem.wpn2 = 0;
9109 269 tempitem.wpn3 = 0;
9110 269 tempitem.wpn4 = 0;
9111 269 tempitem.wpn5 = 0;
9112 269 tempitem.wpn6 = 0;
9113 269 tempitem.wpn7 = 0;
9114 269 tempitem.wpn8 = 0;
9115 269 tempitem.wpn9 = 0;
9116 269 tempitem.wpn10 = 0;
9117 269 break;
9118 }
9119 case itype_perilring:
9120 {
9121 295 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9122 295 tempitem.misc2 = 0;
9123 295 tempitem.misc3 = 0;
9124 295 tempitem.misc4 = 0;
9125 295 tempitem.misc5 = 0;
9126 295 tempitem.misc6 = 0;
9127 295 tempitem.misc7 = 0;
9128 295 tempitem.misc8 = 0;
9129 295 tempitem.misc9 = 0;
9130 295 tempitem.misc10 = 0;
9131 295 tempitem.wpn = 0;
9132 295 tempitem.wpn2 = 0;
9133 295 tempitem.wpn3 = 0;
9134 295 tempitem.wpn4 = 0;
9135 295 tempitem.wpn5 = 0;
9136 295 tempitem.wpn6 = 0;
9137 295 tempitem.wpn7 = 0;
9138 295 tempitem.wpn8 = 0;
9139 295 tempitem.wpn9 = 0;
9140 295 tempitem.wpn10 = 0;
9141 295 break;
9142 }
9143 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9144 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9145 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9146 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9147 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9148 {
9149 9413 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9150 9413 tempitem.misc1 = 0;
9151 9413 tempitem.misc2 = 0;
9152 9413 tempitem.misc3 = 0;
9153 9413 tempitem.misc4 = 0;
9154 9413 tempitem.misc5 = 0;
9155 9413 tempitem.misc6 = 0;
9156 9413 tempitem.misc7 = 0;
9157 9413 tempitem.misc8 = 0;
9158 9413 tempitem.misc9 = 0;
9159 9413 tempitem.misc10 = 0;
9160 9413 tempitem.wpn = 0;
9161 9413 tempitem.wpn2 = 0;
9162 9413 tempitem.wpn3 = 0;
9163 9413 tempitem.wpn4 = 0;
9164 9413 tempitem.wpn5 = 0;
9165 9413 tempitem.wpn6 = 0;
9166 9413 tempitem.wpn7 = 0;
9167 9413 tempitem.wpn8 = 0;
9168 9413 tempitem.wpn9 = 0;
9169 9413 tempitem.wpn10 = 0;
9170 9413 break;
9171 }
9172 }
9173 69376 }
9174 //Port quest rules to items
9175
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 69376 times.
177152 if( s_version <= 31)
9176 {
9177
2/2
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 69091 times.
69376 if(tempitem.family == itype_bomb)
9178 {
9179
2/2
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 130 times.
285 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9180 130 else tempitem.flags &= ~ item_flag2;
9181 285 }
9182
2/2
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 68820 times.
69091 else if(tempitem.family == itype_sbomb)
9183 {
9184
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 114 times.
271 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9185 114 else tempitem.flags &= ~ item_flag2;
9186 271 }
9187
9188
2/2
✓ Branch 0 taken 813 times.
✓ Branch 1 taken 68007 times.
68820 else if(tempitem.family == itype_brang)
9189 {
9190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 813 times.
813 if ( get_qr(qr_BRANGPICKUP) ) tempitem.flags |= item_flag4;
9191 813 else tempitem.flags &= ~ item_flag4;
9192 813 }
9193
2/2
✓ Branch 0 taken 67720 times.
✓ Branch 1 taken 287 times.
68007 else if(tempitem.family == itype_wand)
9194 {
9195
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 268 times.
287 if ( get_qr(qr_NOWANDMELEE) ) tempitem.flags |= item_flag3;
9196 268 else tempitem.flags &= ~ item_flag3;
9197 287 }
9198 69376 }
9199
9200 //Port quest rules to items
9201
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 69376 times.
177152 if( s_version <= 37)
9202 {
9203
2/2
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 69105 times.
69376 if(tempitem.family == itype_flippers)
9204 {
9205
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 193 times.
271 if ( (get_qr(qr_NODIVING)) ) tempitem.flags |= item_flag1;
9206 193 else tempitem.flags &= ~ item_flag1;
9207 271 }
9208
2/2
✓ Branch 0 taken 51590 times.
✓ Branch 1 taken 17515 times.
69105 else if(tempitem.family == itype_sword)
9209 {
9210
2/2
✓ Branch 0 taken 462 times.
✓ Branch 1 taken 17053 times.
17515 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9211 17053 else tempitem.flags &= ~ item_flag5;
9212 17515 }
9213
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 51303 times.
51590 else if(tempitem.family == itype_wand)
9214 {
9215
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 277 times.
287 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9216 277 else tempitem.flags &= ~ item_flag5;
9217 287 }
9218
4/4
✓ Branch 0 taken 51018 times.
✓ Branch 1 taken 285 times.
✓ Branch 2 taken 580 times.
✓ Branch 3 taken 50438 times.
51303 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9219 {
9220 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9221
2/2
✓ Branch 0 taken 375 times.
✓ Branch 1 taken 490 times.
865 if ( (get_qr(qr_FIREPROOFHERO)) ) tempitem.flags |= item_flag3;
9222 490 else tempitem.flags &= ~ item_flag3;
9223 865 }
9224 69376 }
9225
9226
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 69376 times.
177152 if( s_version < 38)
9227 {
9228
4/4
✓ Branch 0 taken 68563 times.
✓ Branch 1 taken 813 times.
✓ Branch 2 taken 540 times.
✓ Branch 3 taken 68023 times.
69376 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9229 {
9230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1353 times.
1353 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9231 1353 else tempitem.flags &= ~item_flag4;
9232
9233
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 681 times.
1353 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags |= item_flag5 | item_flag6;
9234 681 else tempitem.flags &= ~(item_flag5|item_flag6);
9235 1353 }
9236
2/2
✓ Branch 0 taken 67222 times.
✓ Branch 1 taken 801 times.
68023 else if(tempitem.family == itype_arrow)
9237 {
9238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 801 times.
801 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9239 801 else tempitem.flags &= ~item_flag4;
9240
9241
2/2
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 405 times.
801 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags &= ~item_flag2;
9242 405 else tempitem.flags |= item_flag2;
9243 801 }
9244 69376 }
9245
9246
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 69376 times.
177152 if( s_version < 39)
9247 {
9248
6/6
✓ Branch 0 taken 69107 times.
✓ Branch 1 taken 269 times.
✓ Branch 2 taken 68822 times.
✓ Branch 3 taken 285 times.
✓ Branch 4 taken 580 times.
✓ Branch 5 taken 68242 times.
69376 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9249 {
9250
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1118 times.
1134 if(get_qr(qr_TEMPCANDLELIGHT)) tempitem.flags |= item_flag5;
9251 1118 else tempitem.flags &= ~item_flag5;
9252 1134 }
9253
2/2
✓ Branch 0 taken 593 times.
✓ Branch 1 taken 67649 times.
68242 else if(tempitem.family == itype_potion)
9254 {
9255
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 431 times.
593 if(get_qr(qr_NONBUBBLEMEDICINE))
9256 {
9257 162 tempitem.flags &= ~(item_flag3|item_flag4);
9258 162 }
9259 else
9260 {
9261 431 tempitem.flags |= item_flag3;
9262
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 310 times.
431 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9263 310 else tempitem.flags &= ~item_flag4;
9264 }
9265 593 }
9266
2/2
✓ Branch 0 taken 67111 times.
✓ Branch 1 taken 538 times.
67649 else if(tempitem.family == itype_triforcepiece)
9267 {
9268
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 454 times.
538 if(get_qr(qr_NONBUBBLETRIFORCE))
9269 {
9270 84 tempitem.flags |= item_flag3;
9271
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 28 times.
84 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9272 28 else tempitem.flags &= ~item_flag4;
9273 84 }
9274 else
9275 {
9276 454 tempitem.flags &= ~(item_flag3|item_flag4);
9277 }
9278 538 }
9279 69376 }
9280
9281
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 69376 times.
177152 if( s_version < 40)
9282 {
9283
4/4
✓ Branch 0 taken 68515 times.
✓ Branch 1 taken 861 times.
✓ Branch 2 taken 295 times.
✓ Branch 3 taken 68220 times.
69376 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9284 {
9285
2/2
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 890 times.
1156 if(get_qr(qr_RINGAFFECTDAMAGE))tempitem.flags |= item_flag1;
9286 890 else tempitem.flags &= ~item_flag1;
9287 1156 }
9288
8/8
✓ Branch 0 taken 67640 times.
✓ Branch 1 taken 580 times.
✓ Branch 2 taken 50125 times.
✓ Branch 3 taken 17515 times.
✓ Branch 4 taken 49838 times.
✓ Branch 5 taken 287 times.
✓ Branch 6 taken 269 times.
✓ Branch 7 taken 49569 times.
68220 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9289 {
9290
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 18543 times.
18651 if(get_qr(qr_SLASHFLIPFIX))tempitem.flags |= item_flag8;
9291 18543 else tempitem.flags &= ~item_flag8;
9292 18651 }
9293
6/6
✓ Branch 0 taken 51861 times.
✓ Branch 1 taken 17515 times.
✓ Branch 2 taken 51574 times.
✓ Branch 3 taken 287 times.
✓ Branch 4 taken 271 times.
✓ Branch 5 taken 51303 times.
69376 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9294 {
9295
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 17969 times.
18073 if(get_qr(qr_NOITEMMELEE))tempitem.flags |= item_flag7;
9296 17969 else tempitem.flags &= ~item_flag7;
9297 18073 }
9298
2/2
✓ Branch 0 taken 51034 times.
✓ Branch 1 taken 269 times.
51303 else if(tempitem.family == itype_cbyrna)
9299 {
9300 269 tempitem.flags |= item_flag7;
9301 269 }
9302 69376 }
9303
9304
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 69376 times.
177152 if( s_version < 41 )
9305 {
9306
2/2
✓ Branch 0 taken 51861 times.
✓ Branch 1 taken 17515 times.
69376 if(tempitem.family == itype_sword)
9307 {
9308
2/2
✓ Branch 0 taken 188 times.
✓ Branch 1 taken 17327 times.
17515 if(get_qr(qr_SWORDMIRROR))tempitem.flags |= item_flag9;
9309 17327 else tempitem.flags &= ~item_flag9;
9310
9311
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 17087 times.
17515 if(get_qr(qr_SLOWCHARGINGWALK))tempitem.flags |= item_flag10;
9312 17087 else tempitem.flags &= ~item_flag10;
9313 17515 }
9314 69376 }
9315
9316
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 69376 times.
177152 if( s_version < 42 )
9317 {
9318
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 69089 times.
69376 if(tempitem.family == itype_wand)
9319 {
9320
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 268 times.
287 if(get_qr(qr_NOWANDMELEE))tempitem.flags |= item_flag3;
9321 268 else tempitem.flags &= ~item_flag3;
9322
9323 287 tempitem.flags &= ~item_flag6;
9324 287 }
9325
2/2
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 68818 times.
69089 else if(tempitem.family == itype_hammer)
9326 {
9327 271 tempitem.flags &= ~item_flag3;
9328 271 }
9329
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 68549 times.
68818 else if(tempitem.family == itype_cbyrna)
9330 {
9331 269 tempitem.flags |= item_flag3;
9332
9333 269 tempitem.flags &= ~item_flag6;
9334 269 }
9335
2/2
✓ Branch 0 taken 51034 times.
✓ Branch 1 taken 17515 times.
68549 else if(tempitem.family == itype_sword)
9336 {
9337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17515 times.
17515 if(get_qr(qr_MELEEMAGICCOST))tempitem.flags |= item_flag6;
9338 17515 else tempitem.flags &= ~item_flag6;
9339 17515 }
9340 69376 }
9341
9342
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 69376 times.
177152 if( s_version < 43 )
9343 {
9344
2/2
✓ Branch 0 taken 69059 times.
✓ Branch 1 taken 317 times.
69376 if(tempitem.family == itype_whistle)
9345 {
9346
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 309 times.
317 if(get_qr(qr_WHIRLWINDMIRROR))tempitem.flags |= item_flag3;
9347 309 else tempitem.flags &= ~item_flag3;
9348 317 }
9349 69376 }
9350
9351
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 69376 times.
177152 if( s_version < 45 )
9352 {
9353
2/2
✓ Branch 0 taken 69105 times.
✓ Branch 1 taken 271 times.
69376 if(tempitem.family == itype_flippers)
9354 {
9355 271 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9356 271 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9357 271 }
9358 69376 }
9359
9360
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 69376 times.
177152 if( s_version < 46 )
9361 {
9362
2/2
✓ Branch 0 taken 69107 times.
✓ Branch 1 taken 269 times.
69376 if(tempitem.family == itype_raft)
9363 {
9364 269 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9365 269 }
9366 69376 }
9367
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 69376 times.
177152 if ( s_version < 34 ) //! set the default counter for older quests.
9368 {
9369
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 69270 times.
69376 if ( (tempitem.flags & item_rupee_magic) )
9370 {
9371 106 tempitem.cost_counter[0] = 1;
9372 106 }
9373 else
9374 {
9375
2/2
✓ Branch 0 taken 42240 times.
✓ Branch 1 taken 27030 times.
69270 if(get_qr(qr_ENABLEMAGIC))
9376 42240 tempitem.cost_counter[0] = 4;
9377 else
9378 {
9379 27030 tempitem.cost_amount[0] = 0;
9380 27030 tempitem.cost_counter[0] = -1;
9381 }
9382 }
9383 69376 }
9384
9385
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 69376 times.
177152 if ( s_version < 35 ) //new Lens of Truth flags
9386 {
9387
2/2
✓ Branch 0 taken 69131 times.
✓ Branch 1 taken 245 times.
69376 if ( tempitem.family == itype_lens )
9388 {
9389
2/2
✓ Branch 0 taken 237 times.
✓ Branch 1 taken 8 times.
245 if ( get_qr(qr_RAFTLENS) )
9390 {
9391 8 tempitem.flags |= item_flag4;
9392 8 }
9393
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 166 times.
245 if ( get_qr(qr_LENSHINTS) )
9394 {
9395 166 tempitem.flags |= item_flag1;
9396 166 }
9397
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 11 times.
245 if ( get_qr(qr_LENSSEESENEMIES) )
9398 {
9399 11 tempitem.flags |= item_flag5;
9400 11 }
9401 245 }
9402 69376 }
9403
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 69376 times.
177152 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9404 {
9405
2/2
✓ Branch 0 taken 555008 times.
✓ Branch 1 taken 69376 times.
624384 for ( int32_t q = 0; q < 8; q++ )
9406 {
9407 555008 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9408 555008 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9409 555008 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9410 555008 tempitem.sprite_initiald[q] = 0;
9411 555008 }
9412
2/2
✓ Branch 0 taken 138752 times.
✓ Branch 1 taken 69376 times.
208128 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9413 69376 tempitem.sprite_script = 0;
9414 69376 }
9415
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 69376 times.
177152 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9416 {
9417 69376 tempitem.pickupflag = 0;
9418 69376 }
9419
9420
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 69376 times.
177152 if( s_version < 51 )
9421 {
9422
2/2
✓ Branch 0 taken 68796 times.
✓ Branch 1 taken 580 times.
69376 if( tempitem.family == itype_candle )
9423 {
9424 580 tempitem.misc4 = 50; //Step speed
9425 580 }
9426 69376 }
9427
9428
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 69376 times.
177152 if( s_version < 52 )
9429 {
9430
2/2
✓ Branch 0 taken 68555 times.
✓ Branch 1 taken 821 times.
69376 if( tempitem.family == itype_shield )
9431 821 tempitem.flags |= item_flag1; //'Block Front' flag
9432 69376 }
9433
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 69376 times.
177152 if(s_version < 53)
9434 {
9435
4/4
✓ Branch 0 taken 68019 times.
✓ Branch 1 taken 801 times.
✓ Branch 2 taken 285 times.
✓ Branch 3 taken 271 times.
69376 switch(tempitem.family)
9436 {
9437 case itype_arrow:
9438 801 tempitem.cost_counter[1] = crARROWS;
9439 801 tempitem.cost_amount[1] = 1;
9440 801 break;
9441 case itype_bomb:
9442 285 tempitem.cost_counter[1] = crBOMBS;
9443 285 tempitem.cost_amount[1] = 1;
9444 285 break;
9445 case itype_sbomb:
9446 271 tempitem.cost_counter[1] = crSBOMBS;
9447 271 tempitem.cost_amount[1] = 1;
9448 271 break;
9449 default:
9450 68019 tempitem.cost_counter[1] = crNONE;
9451 68019 tempitem.cost_amount[1] = 0;
9452 68019 }
9453 69376 tempitem.magiccosttimer[1] = 0;
9454 69376 }
9455
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 72192 times.
177152 if( s_version < 54 )
9456 {
9457
2/2
✓ Branch 0 taken 71908 times.
✓ Branch 1 taken 284 times.
72192 if( tempitem.family == itype_flippers )
9458 284 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9459 72192 }
9460
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 72192 times.
177152 if(s_version < 55)
9461 {
9462
3/3
✓ Branch 0 taken 560 times.
✓ Branch 1 taken 560 times.
✓ Branch 2 taken 71072 times.
72192 switch(tempitem.family)
9463 {
9464 case itype_spinscroll:
9465 case itype_quakescroll:
9466 560 tempitem.usesound2 = WAV_ZN1CHARGE;
9467 560 break;
9468 case itype_spinscroll2:
9469 case itype_quakescroll2:
9470 560 tempitem.usesound2 = WAV_ZN1CHARGE2;
9471 560 break;
9472 }
9473 72192 }
9474
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 72192 times.
177152 if(s_version < 56)
9475 {
9476
4/4
✓ Branch 0 taken 71010 times.
✓ Branch 1 taken 280 times.
✓ Branch 2 taken 606 times.
✓ Branch 3 taken 296 times.
72192 switch(tempitem.family)
9477 {
9478 case itype_divinefire:
9479
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 11 times.
280 SETFLAG(tempitem.flags, item_flag9, version < 0x255); //Strong Fire
9480
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 198 times.
280 SETFLAG(tempitem.flags, item_flag10, version < 0x250); //Magic Fire
9481 280 tempitem.flags |= item_flag11; //Divine Fire
9482 280 break;
9483 case itype_candle:
9484
2/2
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 304 times.
606 SETFLAG(tempitem.flags, item_flag9, tempitem.fam_type > 1); //Strong Fire
9485 606 tempitem.flags &= ~item_flag10; //Magic Fire
9486 606 tempitem.flags &= ~item_flag11; //Divine Fire
9487 606 break;
9488 case itype_book:
9489 296 tempitem.flags |= item_flag9; //Strong Fire
9490 296 tempitem.flags |= item_flag10; //Magic Fire
9491 296 tempitem.flags &= ~item_flag11; //Divine Fire
9492 296 break;
9493 }
9494 72192 }
9495
9496
2/2
✓ Branch 0 taken 166164 times.
✓ Branch 1 taken 10988 times.
177152 if(tempitem.fam_type==0) // Always do this
9497 10988 tempitem.fam_type=1;
9498
9499 177152 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9500 177152 }
9501
9502 692 return 0;
9503 693 }
9504
9505 static bool did_init_def_items = false;
9506 354170 void init_def_items()
9507 {
9508
2/2
✓ Branch 0 taken 353858 times.
✓ Branch 1 taken 312 times.
354170 if(did_init_def_items) return;
9509 312 did_init_def_items = true;
9510 312 default_items[3].cost_counter[1] = crBOMBS;
9511 312 default_items[13].cost_counter[1] = crARROWS;
9512 312 default_items[14].cost_counter[1] = crARROWS;
9513 312 default_items[48].cost_counter[1] = crSBOMBS;
9514 312 default_items[57].cost_counter[1] = crARROWS;
9515 354170 }
9516 354170 void reset_itembuf(itemdata *item, int32_t id)
9517 {
9518 354170 init_def_items();
9519
2/2
✓ Branch 0 taken 151081 times.
✓ Branch 1 taken 203089 times.
354170 if(id<iLast)
9520 {
9521 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9522 203089 word tile = item->tile;
9523 203089 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9524 203089 int32_t ltm = item->ltm;
9525
9526 203089 memcpy(item,&default_items[id],sizeof(itemdata));
9527 203089 item->tile = tile;
9528 203089 item->misc_flags = miscs;
9529 203089 item->csets = cset;
9530 203089 item->frames = frames;
9531 203089 item->speed = speed;
9532 203089 item->delay = delay;
9533 203089 item->ltm = ltm;
9534 203089 }
9535 354170 }
9536
9537 88832 void reset_itemname(int32_t id)
9538 {
9539 88832 sprintf(item_string[id],"zz%03d",id);
9540
9541
2/2
✓ Branch 0 taken 39211 times.
✓ Branch 1 taken 49621 times.
88832 if(id < iLast)
9542 49621 strcpy(item_string[id],old_item_string[id]);
9543 88832 }
9544
9545 693 int32_t readweapons(PACKFILE *f, zquestheader *Header)
9546 {
9547
2/2
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 24 times.
693 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_weapons);
9548
9549 693 word weapons_to_read=MAXWPNS;
9550 int32_t dummy;
9551 byte padding;
9552 wpndata tempweapon;
9553 693 word s_version=0, s_cversion=0;
9554
9555
9556
2/2
✓ Branch 0 taken 687 times.
✓ Branch 1 taken 6 times.
693 if(Header->zelda_version < 0x186)
9557 {
9558 6 weapons_to_read=64;
9559 6 }
9560
9561
2/2
✓ Branch 0 taken 687 times.
✓ Branch 1 taken 6 times.
693 if(Header->zelda_version < 0x185)
9562 {
9563 6 weapons_to_read=32;
9564 6 }
9565
9566
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 669 times.
693 if(Header->zelda_version > 0x192)
9567 {
9568 669 weapons_to_read=0;
9569
9570 //section version info
9571
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&s_version,f))
9572 {
9573 return qe_invalid;
9574 }
9575
9576 669 FFCore.quest_format[vWeaponSprites] = s_version;
9577
9578
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&s_cversion,f))
9579 {
9580 return qe_invalid;
9581 }
9582
9583 //section size
9584
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetl(&dummy,f))
9585 {
9586 return qe_invalid;
9587 }
9588
9589 //finally... section data
9590
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&weapons_to_read,f))
9591 {
9592 return qe_invalid;
9593 }
9594
9595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
669 if (weapons_to_read > MAXWPNS)
9596 {
9597 return qe_invalid;
9598 }
9599 669 }
9600
9601
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 83 times.
693 if(s_version>2)
9602 {
9603
2/2
✓ Branch 0 taken 156160 times.
✓ Branch 1 taken 610 times.
156770 for(int32_t i=0; i<weapons_to_read; i++)
9604 {
9605 char tempname[64];
9606
9607
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if(!pfread(tempname, 64, f))
9608 {
9609 return qe_invalid;
9610 }
9611
9612 156160 weapon_string[i][0] = '\0';
9613 156160 strncat(weapon_string[i], tempname, 64 - 1);
9614 156160 }
9615
9616
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(s_version<4)
9617 {
9618 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9619 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9620 }
9621
9622
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(s_version<5)
9623 {
9624 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9625 }
9626
9627 /*
9628 if (s_version<6)
9629 {
9630 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9631 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9632 }
9633 */
9634 610 }
9635
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
9636 {
9637
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXWPNS; i++)
9638 20992 reset_weaponname(i);
9639 82 }
9640
9641
2/2
✓ Branch 0 taken 164972 times.
✓ Branch 1 taken 693 times.
165665 for(int32_t i=0; i<weapons_to_read; i++)
9642 {
9643 164972 word oldtile = 0;
9644
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 58476 times.
164972 if (s_version < 8)
9645 {
9646
1/2
✓ Branch 0 taken 58476 times.
✗ Branch 1 not taken.
58476 if (!p_igetw(&oldtile, f))
9647 return qe_invalid;
9648 58476 }
9649
9650
1/2
✓ Branch 0 taken 164972 times.
✗ Branch 1 not taken.
164972 if(!p_getc(&tempweapon.misc,f))
9651 {
9652 return qe_invalid;
9653 }
9654
9655
1/2
✓ Branch 0 taken 164972 times.
✗ Branch 1 not taken.
164972 if(!p_getc(&tempweapon.csets,f))
9656 {
9657 return qe_invalid;
9658 }
9659
9660
1/2
✓ Branch 0 taken 164972 times.
✗ Branch 1 not taken.
164972 if(!p_getc(&tempweapon.frames,f))
9661 {
9662 return qe_invalid;
9663 }
9664
9665
1/2
✓ Branch 0 taken 164972 times.
✗ Branch 1 not taken.
164972 if(!p_getc(&tempweapon.speed,f))
9666 {
9667 return qe_invalid;
9668 }
9669
9670
1/2
✓ Branch 0 taken 164972 times.
✗ Branch 1 not taken.
164972 if(!p_getc(&tempweapon.type,f))
9671 {
9672 return qe_invalid;
9673 }
9674
9675
2/2
✓ Branch 0 taken 57196 times.
✓ Branch 1 taken 107776 times.
164972 if ( s_version >= 7 )
9676 {
9677
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if(!p_igetw(&tempweapon.script,f))
9678 {
9679 return qe_invalid;
9680 }
9681
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if(!p_igetl(&tempweapon.tile,f))
9682 {
9683 return qe_invalid;
9684 }
9685 107776 }
9686
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 57196 times.
164972 if ( s_version < 7 )
9687 {
9688 57196 tempweapon.tile = oldtile;
9689 57196 }
9690
9691
2/2
✓ Branch 0 taken 160172 times.
✓ Branch 1 taken 4800 times.
164972 if(Header->zelda_version < 0x193)
9692 {
9693
1/2
✓ Branch 0 taken 4800 times.
✗ Branch 1 not taken.
4800 if(!p_getc(&padding,f))
9694 {
9695 return qe_invalid;
9696 }
9697 4800 }
9698
9699
2/2
✓ Branch 0 taken 156160 times.
✓ Branch 1 taken 8812 times.
164972 if(s_version < 6)
9700 {
9701
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 8794 times.
8812 if(i==ewFIRETRAIL)
9702 {
9703 18 tempweapon.misc |= WF_BEHIND;
9704 18 }
9705 else
9706 8794 tempweapon.misc &= ~WF_BEHIND;
9707 8812 }
9708
9709
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 164716 times.
164972 if (!should_skip)
9710 164716 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9711 164972 }
9712
9713
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 692 times.
693 if (should_skip)
9714 1 return 0;
9715
9716
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 610 times.
692 if(s_version<2)
9717 {
9718 82 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9719 82 }
9720
9721
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 610 times.
692 if(s_version<5)
9722 {
9723 82 wpnsbuf[iwQuarterHearts].tile=1;
9724 82 wpnsbuf[iwQuarterHearts].csets=1;
9725 82 }
9726
9727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
692 if(Header->zelda_version < 0x176)
9728 {
9729 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9730 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9731 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9732 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9733 }
9734
9735
3/4
✓ Branch 0 taken 674 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
697 if((Header->zelda_version < 0x192)||
9736
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 669 times.
674 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9737 {
9738 18 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9739 18 }
9740
9741
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 669 times.
692 if((Header->zelda_version < 0x210))
9742 {
9743 23 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9744 23 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9745 23 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9746 23 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9747 23 }
9748
9749 692 return 0;
9750 693 }
9751
9752 692 void init_guys(int32_t guyversion)
9753 {
9754
2/2
✓ Branch 0 taken 354304 times.
✓ Branch 1 taken 692 times.
354996 for(int32_t i=0; i<MAXGUYS; i++)
9755 {
9756 354304 guysbuf[i] = default_guys[0];
9757 354304 }
9758
9759
2/2
✓ Branch 0 taken 122484 times.
✓ Branch 1 taken 692 times.
123176 for(int32_t i=0; i<OLDMAXGUYS; i++)
9760 {
9761 122484 guysbuf[i] = default_guys[i];
9762
2/2
✓ Branch 0 taken 121100 times.
✓ Branch 1 taken 1384 times.
122484 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].attributes[9] == 1) ? iwLargeShadow : iwShadow;
9763 122484 guysbuf[i].spr_death = iwDeath;
9764 122484 guysbuf[i].spr_spawn = iwSpawn;
9765 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9766
4/4
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 107970 times.
✓ Branch 2 taken 14432 times.
✓ Branch 3 taken 82 times.
122484 if(guyversion<=3 && i==ePATRABS)
9767 {
9768 82 guysbuf[i].bosspal=spDIG;
9769 82 guysbuf[i].cset=14;
9770 82 guysbuf[i].attributes[8] = 14;
9771 82 }
9772
9773
2/2
✓ Branch 0 taken 107970 times.
✓ Branch 1 taken 14514 times.
122484 if(guyversion<=3)
9774 {
9775 // Rope/Ghini Flash rules
9776
2/2
✓ Branch 0 taken 4071 times.
✓ Branch 1 taken 10443 times.
14514 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9777 {
9778
2/2
✓ Branch 0 taken 10384 times.
✓ Branch 1 taken 59 times.
10443 if(i==eROPE2)
9779 {
9780 59 guysbuf[i].flags2 &= ~guy_flashing;
9781 59 }
9782 10443 }
9783
9784
2/2
✓ Branch 0 taken 12390 times.
✓ Branch 1 taken 2124 times.
14514 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9785 {
9786
12/12
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 2100 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 2088 times.
✓ Branch 5 taken 12 times.
✓ Branch 6 taken 2076 times.
✓ Branch 7 taken 12 times.
✓ Branch 8 taken 2064 times.
✓ Branch 9 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 11 taken 2052 times.
2124 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9787 {
9788 72 guysbuf[i].flags2 &= ~guy_flashing;
9789 72 }
9790 2124 }
9791
9792
2/2
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
14514 if(i==eGHINI2)
9793 {
9794
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 4 times.
82 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9795 {
9796 4 guysbuf[i].flags2 |= guy_blinking;
9797 4 }
9798
9799
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 38 times.
82 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9800 {
9801 38 guysbuf[i].flags2 |= guy_transparent;
9802 38 }
9803 82 }
9804
9805
4/4
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 14350 times.
14514 if (i == eDIG1 || i == eDIG3)
9806 {
9807 164 guysbuf[i].flags2 |= guy_ignore_kill_all;
9808 164 }
9809 14514 }
9810
9811 // Darknut fix
9812
10/10
✓ Branch 0 taken 121792 times.
✓ Branch 1 taken 692 times.
✓ Branch 2 taken 121100 times.
✓ Branch 3 taken 692 times.
✓ Branch 4 taken 120408 times.
✓ Branch 5 taken 692 times.
✓ Branch 6 taken 119716 times.
✓ Branch 7 taken 692 times.
✓ Branch 8 taken 692 times.
✓ Branch 9 taken 119024 times.
122484 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9813 {
9814
2/2
✓ Branch 0 taken 3100 times.
✓ Branch 1 taken 360 times.
3460 if(get_qr(qr_NEWENEMYTILES))
9815 {
9816 3100 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9817 3100 guysbuf[i].s_width=guysbuf[i].e_width;
9818 3100 guysbuf[i].s_height=guysbuf[i].e_height;
9819 3100 }
9820 360 else guysbuf[i].s_tile=860;
9821
9822
2/2
✓ Branch 0 taken 3050 times.
✓ Branch 1 taken 410 times.
3460 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9823 {
9824 410 guysbuf[i].flags |= guy_bkshield;
9825 410 }
9826 3460 }
9827
9828
4/4
✓ Branch 0 taken 121792 times.
✓ Branch 1 taken 692 times.
✓ Branch 2 taken 122434 times.
✓ Branch 3 taken 50 times.
122484 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9829 {
9830 50 guysbuf[i].attributes[2] = (i == eFGELTRIB ? eFZOL : eZOL);
9831 50 }
9832 122484 }
9833 692 }
9834
9835 20992 void reset_weaponname(int32_t i)
9836 {
9837
2/2
✓ Branch 0 taken 7216 times.
✓ Branch 1 taken 13776 times.
20992 if(i<wLast)
9838 {
9839 7216 strcpy(weapon_string[i],old_weapon_string[i]);
9840 7216 }
9841 else
9842 13776 sprintf(weapon_string[i],"zz%03d",i);
9843 20992 }
9844
9845 692 void init_item_drop_sets()
9846 {
9847
2/2
✓ Branch 0 taken 177152 times.
✓ Branch 1 taken 692 times.
177844 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9848 {
9849 // item_drop_sets[i] = default_item_drop_sets[0];
9850 177152 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9851 177152 }
9852
9853
2/2
✓ Branch 0 taken 8996 times.
✓ Branch 1 taken 692 times.
9688 for(int32_t i=0; i<isMAX; i++)
9854 {
9855 8996 item_drop_sets[i] = default_item_drop_sets[i];
9856
9857 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9858
2/2
✓ Branch 0 taken 89960 times.
✓ Branch 1 taken 8996 times.
98956 for(int32_t j=0; j<10; ++j)
9859 {
9860 89960 int32_t it = item_drop_sets[i].item[j];
9861
9862
3/4
✓ Branch 0 taken 63480 times.
✓ Branch 1 taken 26480 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4110 times.
89960 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9863
2/2
✓ Branch 0 taken 4110 times.
✓ Branch 1 taken 59370 times.
63480 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9864 {
9865 4110 item_drop_sets[i].chance[j+1]=0;
9866 4110 }
9867
4/4
✓ Branch 0 taken 2768 times.
✓ Branch 1 taken 83082 times.
✓ Branch 2 taken 144 times.
✓ Branch 3 taken 2624 times.
85850 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9868 {
9869 144 item_drop_sets[i].chance[j+1]=0;
9870 144 }
9871
9872 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9873
2/2
✓ Branch 0 taken 89936 times.
✓ Branch 1 taken 24 times.
89960 if(itemsbuf[it].family == itype_misc)
9874 {
9875 // If a non-gameplay item was selected, then item drop was aborted.
9876 // Reflect this by increasing the 'Nothing' chance accordingly.
9877 24 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9878 24 item_drop_sets[i].chance[j+1]=0;
9879 24 }
9880 89960 }
9881 8996 }
9882 692 }
9883
9884 692 void init_favorites()
9885 {
9886
2/2
✓ Branch 0 taken 871920 times.
✓ Branch 1 taken 692 times.
872612 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9887 {
9888 871920 favorite_combos[i]=-1;
9889 871920 }
9890 692 }
9891
9892 const char *ctype_name[cMAX]=
9893 {
9894 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9895 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9896 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9897 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9898 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9899 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9900 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9901 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9902 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9903 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9904 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9905 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9906 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9907 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9908 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9909 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9910 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9911 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9912 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9913 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9914 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9915 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9916 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9917 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9918 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9919 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9920 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9921 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9922
9923 };
9924
9925 968 int32_t init_combo_classes()
9926 {
9927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 968 times.
968 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9928
2/2
✓ Branch 0 taken 177144 times.
✓ Branch 1 taken 968 times.
178112 for(int32_t i=0; i<cMAX; i++)
9929 {
9930 177144 combo_class_buf[i] = default_combo_classes[i];
9931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177144 times.
177144 if ( char const* nm = zi->getComboTypeName(i) )
9932 {
9933 177144 size_t len = strlen(nm);
9934
2/2
✓ Branch 0 taken 11337216 times.
✓ Branch 1 taken 177144 times.
11514360 for ( size_t q = 0; q < 64; q++ )
9935 {
9936
2/2
✓ Branch 0 taken 2595208 times.
✓ Branch 1 taken 8742008 times.
11337216 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9937 11337216 }
9938 177144 }
9939 177144 }
9940
9941 968 return 0;
9942 }
9943
9944 294 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
9945 {
9946
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 248 times.
294 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_herosprites);
9947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
294 if (should_skip) return 0;
9948
9949
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 assert(v_herosprites < 6);
9950 //these are here to bypass compiler warnings about unused arguments
9951 294 cv_herosprites=cv_herosprites;
9952
9953 294 zinit.hero_swim_speed=67; //default
9954 294 setupherotiles(zinit.heroAnimationStyle);
9955 294 setupherodefenses();
9956 294 setupherooffsets();
9957
9958
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 189 times.
294 if(v_herosprites>=0)
9959 {
9960 word tile, tile2;
9961 byte flip, extend, dummy_byte;
9962
9963
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 189 times.
945 for(int32_t i=0; i<4; i++)
9964 {
9965
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_igetw(&tile,f))
9966 {
9967 return qe_invalid;
9968 }
9969
9970
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&flip,f))
9971 {
9972 return qe_invalid;
9973 }
9974
9975
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&extend,f))
9976 {
9977 return qe_invalid;
9978 }
9979
9980 756 walkspr[i][spr_tile]=(int32_t)tile;
9981 756 walkspr[i][spr_flip]=(int32_t)flip;
9982 756 walkspr[i][spr_extend]=(int32_t)extend;
9983 756 }
9984
9985
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 189 times.
945 for(int32_t i=0; i<4; i++)
9986 {
9987
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_igetw(&tile,f))
9988 {
9989 return qe_invalid;
9990 }
9991
9992
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&flip,f))
9993 {
9994 return qe_invalid;
9995 }
9996
9997
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&extend,f))
9998 {
9999 return qe_invalid;
10000 }
10001
10002 756 stabspr[i][spr_tile]=(int32_t)tile;
10003 756 stabspr[i][spr_flip]=(int32_t)flip;
10004 756 stabspr[i][spr_extend]=(int32_t)extend;
10005 756 }
10006
10007
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 189 times.
945 for(int32_t i=0; i<4; i++)
10008 {
10009
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_igetw(&tile,f))
10010 {
10011 return qe_invalid;
10012 }
10013
10014
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&flip,f))
10015 {
10016 return qe_invalid;
10017 }
10018
10019
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&extend,f))
10020 {
10021 return qe_invalid;
10022 }
10023
10024 756 slashspr[i][spr_tile]=(int32_t)tile;
10025 756 slashspr[i][spr_flip]=(int32_t)flip;
10026 756 slashspr[i][spr_extend]=(int32_t)extend;
10027 756 }
10028
10029
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 189 times.
945 for(int32_t i=0; i<4; i++)
10030 {
10031
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_igetw(&tile,f))
10032 {
10033 return qe_invalid;
10034 }
10035
10036
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&flip,f))
10037 {
10038 return qe_invalid;
10039 }
10040
10041
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&extend,f))
10042 {
10043 return qe_invalid;
10044 }
10045
10046 756 floatspr[i][spr_tile]=(int32_t)tile;
10047 756 floatspr[i][spr_flip]=(int32_t)flip;
10048 756 floatspr[i][spr_extend]=(int32_t)extend;
10049 756 }
10050
10051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if(v_herosprites>1)
10052 {
10053
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 189 times.
945 for(int32_t i=0; i<4; i++)
10054 {
10055
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_igetw(&tile,f))
10056 {
10057 return qe_invalid;
10058 }
10059
10060
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&flip,f))
10061 {
10062 return qe_invalid;
10063 }
10064
10065
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&extend,f))
10066 {
10067 return qe_invalid;
10068 }
10069
10070 756 swimspr[i][spr_tile]=(int32_t)tile;
10071 756 swimspr[i][spr_flip]=(int32_t)flip;
10072 756 swimspr[i][spr_extend]=(int32_t)extend;
10073 756 }
10074 189 }
10075
10076
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 189 times.
945 for(int32_t i=0; i<4; i++)
10077 {
10078
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_igetw(&tile,f))
10079 {
10080 return qe_invalid;
10081 }
10082
10083
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&flip,f))
10084 {
10085 return qe_invalid;
10086 }
10087
10088
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&extend,f))
10089 {
10090 return qe_invalid;
10091 }
10092
10093 756 divespr[i][spr_tile]=(int32_t)tile;
10094 756 divespr[i][spr_flip]=(int32_t)flip;
10095 756 divespr[i][spr_extend]=(int32_t)extend;
10096 756 }
10097
10098
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 189 times.
945 for(int32_t i=0; i<4; i++)
10099 {
10100
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_igetw(&tile,f))
10101 {
10102 return qe_invalid;
10103 }
10104
10105
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&flip,f))
10106 {
10107 return qe_invalid;
10108 }
10109
10110
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&extend,f))
10111 {
10112 return qe_invalid;
10113 }
10114
10115 756 poundspr[i][spr_tile]=(int32_t)tile;
10116 756 poundspr[i][spr_flip]=(int32_t)flip;
10117 756 poundspr[i][spr_extend]=(int32_t)extend;
10118 756 }
10119
10120
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(!p_igetw(&tile,f))
10121 {
10122 return qe_invalid;
10123 }
10124
10125 189 flip=0;
10126
10127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if(v_herosprites>0)
10128 {
10129
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(!p_getc(&flip,f))
10130 {
10131 return qe_invalid;
10132 }
10133 189 }
10134
10135
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(!p_getc(&extend,f))
10136 {
10137 return qe_invalid;
10138 }
10139
10140 189 castingspr[spr_tile]=(int32_t)tile;
10141 189 castingspr[spr_flip]=(int32_t)flip;
10142 189 castingspr[spr_extend]=(int32_t)extend;
10143
10144
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(v_herosprites>0)
10145 {
10146 189 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10147
2/2
✓ Branch 0 taken 378 times.
✓ Branch 1 taken 189 times.
567 for(int32_t i=0; i<2; i++)
10148 {
10149
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 378 times.
1134 for(int32_t j=0; j<num_holdsprs; j++)
10150 {
10151
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_igetw(&tile,f))
10152 {
10153 return qe_invalid;
10154 }
10155
10156
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&flip,f))
10157 {
10158 return qe_invalid;
10159 }
10160
10161
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&extend,f))
10162 {
10163 return qe_invalid;
10164 }
10165
10166 756 holdspr[i][j][spr_tile]=(int32_t)tile;
10167 756 holdspr[i][j][spr_flip]=(int32_t)flip;
10168 756 holdspr[i][j][spr_extend]=(int32_t)extend;
10169 756 }
10170 378 }
10171 189 }
10172 else
10173 {
10174 for(int32_t i=0; i<2; i++)
10175 {
10176 if(!p_igetw(&tile,f))
10177 {
10178 return qe_invalid;
10179 }
10180
10181 if(!p_igetw(&tile2,f))
10182 {
10183 return qe_invalid;
10184 }
10185
10186 if(!p_getc(&extend,f))
10187 {
10188 return qe_invalid;
10189 }
10190
10191 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10192 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10193 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10194 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10195 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10196 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10197 }
10198 }
10199
10200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if(v_herosprites>2)
10201 {
10202
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 189 times.
945 for(int32_t i=0; i<4; i++)
10203 {
10204
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_igetw(&tile,f))
10205 {
10206 return qe_invalid;
10207 }
10208
10209
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&flip,f))
10210 {
10211 return qe_invalid;
10212 }
10213
10214
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&extend,f))
10215 {
10216 return qe_invalid;
10217 }
10218
10219 756 jumpspr[i][spr_tile]=(int32_t)tile;
10220 756 jumpspr[i][spr_flip]=(int32_t)flip;
10221 756 jumpspr[i][spr_extend]=(int32_t)extend;
10222 756 }
10223 189 }
10224
10225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if(v_herosprites>3)
10226 {
10227
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 189 times.
945 for(int32_t i=0; i<4; i++)
10228 {
10229
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_igetw(&tile,f))
10230 {
10231 return qe_invalid;
10232 }
10233
10234
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&flip,f))
10235 {
10236 return qe_invalid;
10237 }
10238
10239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 756 times.
756 if(!p_getc(&extend,f))
10240 {
10241 return qe_invalid;
10242 }
10243
10244 756 chargespr[i][spr_tile]=(int32_t)tile;
10245 756 chargespr[i][spr_flip]=(int32_t)flip;
10246 756 chargespr[i][spr_extend]=(int32_t)extend;
10247 756 }
10248 189 }
10249
10250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if(v_herosprites>4)
10251 {
10252
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(!p_getc(&dummy_byte,f))
10253 {
10254 return qe_invalid;
10255 }
10256
10257 189 zinit.hero_swim_speed=(byte)dummy_byte;
10258 189 }
10259
10260 189 memset(frozenspr, 0, sizeof(frozenspr));
10261 189 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10262 189 memset(onfirespr, 0, sizeof(onfirespr));
10263 189 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10264 189 memset(diggingspr, 0, sizeof(diggingspr));
10265 189 memset(usingrodspr, 0, sizeof(usingrodspr));
10266 189 memset(usingcanespr, 0, sizeof(usingcanespr));
10267 189 memset(pushingspr, 0, sizeof(pushingspr));
10268 189 memset(liftingspr, 0, sizeof(liftingspr));
10269 189 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10270 189 memset(stunnedspr, 0, sizeof(stunnedspr));
10271 189 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10272 189 memset(fallingspr, 0, sizeof(fallingspr));
10273 189 memset(shockedspr, 0, sizeof(shockedspr));
10274 189 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10275 189 memset(pullswordspr, 0, sizeof(pullswordspr));
10276 189 memset(readingspr, 0, sizeof(readingspr));
10277 189 memset(slash180spr, 0, sizeof(slash180spr));
10278 189 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10279 189 memset(dashspr, 0, sizeof(dashspr));
10280 189 memset(bonkspr, 0, sizeof(bonkspr));
10281 189 memset(medallionsprs, 0, sizeof(medallionsprs));
10282 189 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10283 189 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10284
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 189 times.
945 for(int32_t q = 0; q < 4; ++q)
10285 {
10286
2/2
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 756 times.
3024 for(int32_t p = 0; p < 3; ++p)
10287 {
10288 2268 drowningspr[q][p] = divespr[q][p];
10289 2268 drowning_lavaspr[q][p] = divespr[q][p];
10290 2268 }
10291 756 }
10292 189 memset(sideswimspr, 0, sizeof(sideswimspr));
10293 189 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10294 189 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10295 189 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10296 189 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10297 189 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10298 189 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10299 189 }
10300
10301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
294 if(FFCore.quest_format[vInitData] < 34)
10302 {
10303 294 bool fastswim = zinit.hero_swim_speed > 60;
10304 // '2/3' or '1/2'
10305 294 zinit.hero_swim_mult = fastswim ? 2 : 1;
10306 294 zinit.hero_swim_div = fastswim ? 3 : 2;
10307 294 }
10308 294 return 0;
10309 294 }
10310
10311 71570 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10312 {
10313 71570 arr[spr_tile] = tile;
10314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71570 times.
71570 arr[spr_flip] = (flip > 3 ? 0 : flip);
10315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71570 times.
71570 arr[spr_extend] = (ext > 2 ? 0 : ext);
10316 71570 }
10317 //Used to read the player sprites as int32_t, not word.
10318 421 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
10319 {
10320 //these are here to bypass compiler warnings about unused arguments
10321 421 cv_herosprites=cv_herosprites;
10322
10323 421 zinit.hero_swim_speed=67; //default
10324 421 setupherotiles(zinit.heroAnimationStyle);
10325 421 setupherodefenses();
10326 421 setupherooffsets();
10327
10328 int32_t tile, tile2;
10329 byte flip, extend, dummy_byte;
10330
10331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
421 if(v_herosprites>=0)
10332 {
10333
10334
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t i=0; i<4; i++)
10335 {
10336
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10337 {
10338 return qe_invalid;
10339 }
10340
10341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&flip,f))
10342 {
10343 return qe_invalid;
10344 }
10345
10346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
10347 {
10348 return qe_invalid;
10349 }
10350
10351 1684 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10352 1684 }
10353
10354
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t i=0; i<4; i++)
10355 {
10356
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10357 {
10358 return qe_invalid;
10359 }
10360
10361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&flip,f))
10362 {
10363 return qe_invalid;
10364 }
10365
10366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
10367 {
10368 return qe_invalid;
10369 }
10370
10371 1684 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10372 1684 }
10373
10374
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t i=0; i<4; i++)
10375 {
10376
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10377 {
10378 return qe_invalid;
10379 }
10380
10381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&flip,f))
10382 {
10383 return qe_invalid;
10384 }
10385
10386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
10387 {
10388 return qe_invalid;
10389 }
10390
10391 1684 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10392 1684 }
10393
10394
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t i=0; i<4; i++)
10395 {
10396
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10397 {
10398 return qe_invalid;
10399 }
10400
10401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&flip,f))
10402 {
10403 return qe_invalid;
10404 }
10405
10406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
10407 {
10408 return qe_invalid;
10409 }
10410
10411 1684 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10412 1684 }
10413
10414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
421 if(v_herosprites>1)
10415 {
10416
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t i=0; i<4; i++)
10417 {
10418
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10419 {
10420 return qe_invalid;
10421 }
10422
10423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&flip,f))
10424 {
10425 return qe_invalid;
10426 }
10427
10428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
10429 {
10430 return qe_invalid;
10431 }
10432
10433 1684 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10434 1684 }
10435 421 }
10436
10437
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t i=0; i<4; i++)
10438 {
10439
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10440 {
10441 return qe_invalid;
10442 }
10443
10444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&flip,f))
10445 {
10446 return qe_invalid;
10447 }
10448
10449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
10450 {
10451 return qe_invalid;
10452 }
10453
10454 1684 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10455 1684 }
10456
10457
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t i=0; i<4; i++)
10458 {
10459
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10460 {
10461 return qe_invalid;
10462 }
10463
10464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&flip,f))
10465 {
10466 return qe_invalid;
10467 }
10468
10469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
10470 {
10471 return qe_invalid;
10472 }
10473
10474 1684 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10475 1684 }
10476
10477
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_igetl(&tile,f))
10478 {
10479 return qe_invalid;
10480 }
10481
10482 421 flip=0;
10483
10484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
421 if(v_herosprites>0)
10485 {
10486
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_getc(&flip,f))
10487 {
10488 return qe_invalid;
10489 }
10490 421 }
10491
10492
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_getc(&extend,f))
10493 {
10494 return qe_invalid;
10495 }
10496
10497 421 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10498
10499
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(v_herosprites>0)
10500 {
10501 421 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10502
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 421 times.
1263 for(int32_t i=0; i<2; i++)
10503 {
10504
2/2
✓ Branch 0 taken 2526 times.
✓ Branch 1 taken 842 times.
3368 for(int32_t j=0; j<num_holdsprs; j++)
10505 {
10506
1/2
✓ Branch 0 taken 2526 times.
✗ Branch 1 not taken.
2526 if(!p_igetl(&tile,f))
10507 {
10508 return qe_invalid;
10509 }
10510
10511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2526 times.
2526 if(!p_getc(&flip,f))
10512 {
10513 return qe_invalid;
10514 }
10515
10516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2526 times.
2526 if(!p_getc(&extend,f))
10517 {
10518 return qe_invalid;
10519 }
10520
10521 2526 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10522 2526 }
10523 842 }
10524 421 }
10525 else
10526 {
10527 for(int32_t i=0; i<2; i++)
10528 {
10529 if(!p_igetl(&tile,f))
10530 {
10531 return qe_invalid;
10532 }
10533
10534 if(!p_igetl(&tile2,f))
10535 {
10536 return qe_invalid;
10537 }
10538
10539 if(!p_getc(&extend,f))
10540 {
10541 return qe_invalid;
10542 }
10543
10544 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10545 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10546 }
10547 }
10548
10549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
421 if(v_herosprites>2)
10550 {
10551
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t i=0; i<4; i++)
10552 {
10553
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10554 {
10555 return qe_invalid;
10556 }
10557
10558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&flip,f))
10559 {
10560 return qe_invalid;
10561 }
10562
10563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
10564 {
10565 return qe_invalid;
10566 }
10567
10568 1684 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10569 1684 }
10570 421 }
10571
10572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
421 if(v_herosprites>3)
10573 {
10574
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t i=0; i<4; i++)
10575 {
10576
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10577 {
10578 return qe_invalid;
10579 }
10580
10581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&flip,f))
10582 {
10583 return qe_invalid;
10584 }
10585
10586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
10587 {
10588 return qe_invalid;
10589 }
10590
10591 1684 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10592 1684 }
10593 421 }
10594
10595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
421 if(v_herosprites>4)
10596 {
10597
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_getc(&dummy_byte,f))
10598 {
10599 return qe_invalid;
10600 }
10601
10602 421 zinit.hero_swim_speed=(byte)dummy_byte;
10603 421 }
10604
10605
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(v_herosprites>6)
10606 {
10607
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
10608 {
10609
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10610 return qe_invalid;
10611
10612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&flip,f))
10613 return qe_invalid;
10614
10615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
10616 return qe_invalid;
10617
10618 1684 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10619 1684 }
10620
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
10621 {
10622
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10623 return qe_invalid;
10624
10625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&flip,f))
10626 return qe_invalid;
10627
10628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
10629 return qe_invalid;
10630
10631 1684 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10632 1684 }
10633
10634
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
10635 {
10636
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10637 return qe_invalid;
10638
10639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&flip,f))
10640 return qe_invalid;
10641
10642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
10643 return qe_invalid;
10644
10645 1684 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10646 1684 }
10647
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
10648 {
10649
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10650 return qe_invalid;
10651
10652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&flip,f))
10653 return qe_invalid;
10654
10655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
10656 return qe_invalid;
10657
10658 1684 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10659 1684 }
10660
10661
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
10662 {
10663
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10664 return qe_invalid;
10665
10666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&flip,f))
10667 return qe_invalid;
10668
10669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
10670 return qe_invalid;
10671
10672 1684 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10673 1684 }
10674
10675
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
10676 {
10677
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10678 return qe_invalid;
10679
10680
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&flip,f))
10681 return qe_invalid;
10682
10683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
10684 return qe_invalid;
10685
10686 1684 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10687 1684 }
10688
10689
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
10690 {
10691
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10692 return qe_invalid;
10693
10694
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&flip,f))
10695 return qe_invalid;
10696
10697
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&extend,f))
10698 return qe_invalid;
10699
10700 1684 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10701 1684 }
10702
10703
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
10704 {
10705
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10706 return qe_invalid;
10707
10708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&flip,f))
10709 return qe_invalid;
10710
10711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
10712 return qe_invalid;
10713
10714 1684 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10715 1684 }
10716
10717
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
10718 {
10719
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10720 return qe_invalid;
10721
10722
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&flip,f))
10723 return qe_invalid;
10724
10725
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&extend,f))
10726 return qe_invalid;
10727
10728 1684 byte frames = 0;
10729
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1664 times.
1684 if(v_herosprites > 15)
10730 {
10731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1664 times.
1664 if(!p_getc(&frames,f))
10732 return qe_invalid;
10733 1664 }
10734
10735 1684 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10736 1684 liftingspr[q][spr_frames] = frames;
10737 1684 }
10738
10739
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
10740 {
10741
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10742 return qe_invalid;
10743
10744
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&flip,f))
10745 return qe_invalid;
10746
10747
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&extend,f))
10748 return qe_invalid;
10749
10750 1684 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10751 1684 }
10752
10753
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
10754 {
10755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_igetl(&tile,f))
10756 return qe_invalid;
10757
10758
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&flip,f))
10759 return qe_invalid;
10760
10761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
10762 return qe_invalid;
10763
10764 1684 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10765 1684 }
10766
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
10767 {
10768
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10769 return qe_invalid;
10770
10771
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&flip,f))
10772 return qe_invalid;
10773
10774
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&extend,f))
10775 return qe_invalid;
10776
10777 1684 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10778 1684 }
10779
10780
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
10781 {
10782
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10783 return qe_invalid;
10784
10785
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&flip,f))
10786 return qe_invalid;
10787
10788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
10789 return qe_invalid;
10790
10791 1684 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10792 1684 }
10793
10794
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
10795 {
10796
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10797 return qe_invalid;
10798
10799
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&flip,f))
10800 return qe_invalid;
10801
10802
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&extend,f))
10803 return qe_invalid;
10804
10805 1684 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10806 1684 }
10807
10808
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
10809 {
10810
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10811 return qe_invalid;
10812
10813
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&flip,f))
10814 return qe_invalid;
10815
10816
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&extend,f))
10817 return qe_invalid;
10818
10819 1684 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10820 1684 }
10821
10822
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
10823 {
10824
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10825 return qe_invalid;
10826
10827
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&flip,f))
10828 return qe_invalid;
10829
10830
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&extend,f))
10831 return qe_invalid;
10832
10833 1684 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10834 1684 }
10835
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
10836 {
10837
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10838 return qe_invalid;
10839
10840
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&flip,f))
10841 return qe_invalid;
10842
10843
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&extend,f))
10844 return qe_invalid;
10845
10846 1684 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10847 1684 }
10848
10849
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
10850 {
10851
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10852 return qe_invalid;
10853
10854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&flip,f))
10855 return qe_invalid;
10856
10857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
10858 return qe_invalid;
10859
10860 1684 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10861 1684 }
10862
10863
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
10864 {
10865
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10866 return qe_invalid;
10867
10868
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&flip,f))
10869 return qe_invalid;
10870
10871
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&extend,f))
10872 return qe_invalid;
10873
10874 1684 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10875 1684 }
10876
10877
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
10878 {
10879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_igetl(&tile,f))
10880 return qe_invalid;
10881
10882
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&flip,f))
10883 return qe_invalid;
10884
10885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
10886 return qe_invalid;
10887
10888 1684 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10889 1684 }
10890
10891
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
10892 {
10893
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10894 return qe_invalid;
10895
10896
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&flip,f))
10897 return qe_invalid;
10898
10899
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&extend,f))
10900 return qe_invalid;
10901
10902 1684 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10903 1684 }
10904
10905
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
10906 {
10907
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10908 return qe_invalid;
10909
10910
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&flip,f))
10911 return qe_invalid;
10912
10913
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&extend,f))
10914 return qe_invalid;
10915
10916 1684 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10917 1684 }
10918
10919
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
10920 {
10921
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10922 return qe_invalid;
10923
10924
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&flip,f))
10925 return qe_invalid;
10926
10927
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_getc(&extend,f))
10928 return qe_invalid;
10929
10930 1684 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10931 1684 }
10932
10933
2/2
✓ Branch 0 taken 1263 times.
✓ Branch 1 taken 421 times.
1684 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10934 {
10935
1/2
✓ Branch 0 taken 1263 times.
✗ Branch 1 not taken.
1263 if(!p_igetl(&tile,f))
10936 return qe_invalid;
10937
10938
1/2
✓ Branch 0 taken 1263 times.
✗ Branch 1 not taken.
1263 if(!p_getc(&flip,f))
10939 return qe_invalid;
10940
10941
1/2
✓ Branch 0 taken 1263 times.
✗ Branch 1 not taken.
1263 if(!p_getc(&extend,f))
10942 return qe_invalid;
10943
10944 1263 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
10945 1263 }
10946 421 }
10947 else
10948 {
10949 memset(frozenspr, 0, sizeof(frozenspr));
10950 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10951 memset(onfirespr, 0, sizeof(onfirespr));
10952 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10953 memset(diggingspr, 0, sizeof(diggingspr));
10954 memset(usingrodspr, 0, sizeof(usingrodspr));
10955 memset(usingcanespr, 0, sizeof(usingcanespr));
10956 memset(pushingspr, 0, sizeof(pushingspr));
10957 memset(liftingspr, 0, sizeof(liftingspr));
10958 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10959 memset(stunnedspr, 0, sizeof(stunnedspr));
10960 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10961 memset(fallingspr, 0, sizeof(fallingspr));
10962 memset(shockedspr, 0, sizeof(shockedspr));
10963 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10964 memset(pullswordspr, 0, sizeof(pullswordspr));
10965 memset(readingspr, 0, sizeof(readingspr));
10966 memset(slash180spr, 0, sizeof(slash180spr));
10967 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10968 memset(dashspr, 0, sizeof(dashspr));
10969 memset(bonkspr, 0, sizeof(bonkspr));
10970 memset(medallionsprs, 0, sizeof(medallionsprs));
10971 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10972 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10973 for(int32_t q = 0; q < 4; ++q)
10974 {
10975 for(int32_t p = 0; p < 3; ++p)
10976 {
10977 drowningspr[q][p] = divespr[q][p];
10978 drowning_lavaspr[q][p] = divespr[q][p];
10979 }
10980 }
10981 }
10982
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if (v_herosprites > 8)
10983 {
10984
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
10985 {
10986
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
10987 return qe_invalid;
10988
10989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&flip,f))
10990 return qe_invalid;
10991
10992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
10993 return qe_invalid;
10994
10995 1684 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10996 1684 }
10997 421 }
10998 else
10999 {
11000 memset(sideswimspr, 0, sizeof(sideswimspr));
11001 }
11002
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if (v_herosprites > 9)
11003 {
11004
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
11005 {
11006
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
11007 return qe_invalid;
11008
11009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&flip,f))
11010 return qe_invalid;
11011
11012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
11013 return qe_invalid;
11014
11015 1684 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11016 1684 }
11017
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
11018 {
11019
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
11020 return qe_invalid;
11021
11022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&flip,f))
11023 return qe_invalid;
11024
11025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
11026 return qe_invalid;
11027
11028 1684 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11029 1684 }
11030
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
11031 {
11032
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
11033 return qe_invalid;
11034
11035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&flip,f))
11036 return qe_invalid;
11037
11038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
11039 return qe_invalid;
11040
11041 1684 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11042 1684 }
11043
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
11044 {
11045
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
11046 return qe_invalid;
11047
11048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&flip,f))
11049 return qe_invalid;
11050
11051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
11052 return qe_invalid;
11053
11054 1684 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11055 1684 }
11056 421 }
11057 else
11058 {
11059 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11060 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11061 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11062 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11063 }
11064
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if (v_herosprites > 10)
11065 {
11066
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
11067 {
11068 int32_t hmr;
11069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_igetl(&hmr,f))
11070 return qe_invalid;
11071
11072 1684 hammeroffsets[q] = hmr;
11073 1684 }
11074 421 }
11075 else
11076 {
11077 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11078 }
11079
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if (v_herosprites > 11)
11080 {
11081
2/2
✓ Branch 0 taken 1263 times.
✓ Branch 1 taken 421 times.
1684 for(int32_t q = 0; q < 3; ++q)
11082 {
11083
1/2
✓ Branch 0 taken 1263 times.
✗ Branch 1 not taken.
1263 if(!p_igetl(&tile,f))
11084 return qe_invalid;
11085
11086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1263 times.
1263 if(!p_getc(&flip,f))
11087 return qe_invalid;
11088
11089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1263 times.
1263 if(!p_getc(&extend,f))
11090 return qe_invalid;
11091
11092 1263 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11093 1263 }
11094 421 }
11095 else
11096 {
11097 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11098 }
11099
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if (v_herosprites > 12)
11100 {
11101
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_igetl(&tile,f))
11102 return qe_invalid;
11103
11104
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_getc(&flip,f))
11105 return qe_invalid;
11106
11107
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_getc(&extend,f))
11108 return qe_invalid;
11109 421 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11110
11111 421 }
11112 else
11113 {
11114 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11115 }
11116
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if (v_herosprites > 13)
11117 {
11118
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
11119 {
11120
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
11121 return qe_invalid;
11122
11123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&flip,f))
11124 return qe_invalid;
11125
11126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
11127 return qe_invalid;
11128
11129 1684 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11130 1684 }
11131 421 }
11132 else
11133 {
11134 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11135 }
11136
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if (v_herosprites > 14)
11137 {
11138
2/2
✓ Branch 0 taken 1684 times.
✓ Branch 1 taken 421 times.
2105 for(int32_t q = 0; q < 4; ++q)
11139 {
11140
1/2
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
1684 if(!p_igetl(&tile,f))
11141 return qe_invalid;
11142
11143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&flip,f))
11144 return qe_invalid;
11145
11146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
1684 if(!p_getc(&extend,f))
11147 return qe_invalid;
11148
11149 1684 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11150 1684 }
11151 421 }
11152 else
11153 {
11154 memset(revslashspr, 0, sizeof(revslashspr));
11155 }
11156
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if (v_herosprites > 7)
11157 {
11158 421 int32_t num_defense = wMax;
11159 421 byte def = 0;
11160
11161 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11162 /*if(v_herosprites > [x])
11163 * {
11164 * num_defense = 146 //value of wMax on version 8
11165 * }
11166 */
11167
11168
2/2
✓ Branch 0 taken 61466 times.
✓ Branch 1 taken 421 times.
61887 for (int32_t q = 0; q < num_defense; q++)
11169 {
11170
1/2
✓ Branch 0 taken 61466 times.
✗ Branch 1 not taken.
61466 if (!p_getc(&def, f))
11171 return qe_invalid;
11172
11173 61466 hero_defence[q] = def;
11174 61466 }
11175 421 }
11176 else
11177 {
11178 int32_t num_defense = wMax;
11179 for (int32_t q = 0; q < num_defense; q++)
11180 {
11181 hero_defence[q] = 0;
11182 }
11183 }
11184 421 }
11185
11186
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 11 times.
421 if(FFCore.quest_format[vInitData] < 34)
11187 {
11188 11 bool fastswim = zinit.hero_swim_speed > 60;
11189 // '2/3' or '1/2'
11190 11 zinit.hero_swim_mult = fastswim ? 2 : 1;
11191 11 zinit.hero_swim_div = fastswim ? 3 : 2;
11192 11 }
11193 421 return 0;
11194 421 }
11195
11196
11197 610 int32_t readherosprites(PACKFILE *f, zquestheader *Header)
11198 {
11199 //these are here to bypass compiler warnings about unused arguments
11200 610 Header=Header;
11201
11202 dword dummy;
11203 610 word s_version=0, s_cversion=0;
11204
11205 //section version info
11206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if(!p_igetw(&s_version,f))
11207 {
11208 return qe_invalid;
11209 }
11210
11211 610 FFCore.quest_format[vHeroSprites] = s_version;
11212
11213
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_igetw(&s_cversion,f))
11214 {
11215 return qe_invalid;
11216 }
11217
11218 //section size
11219
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_igetl(&dummy,f))
11220 {
11221 return qe_invalid;
11222 }
11223
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 189 times.
610 if ( s_version >= 6 )
11224 {
11225 421 return readherosprites3(f, s_version, dummy);
11226 }
11227 189 else return readherosprites2(f, s_version, dummy);
11228 610 }
11229
11230 207 int32_t read_old_subscreens(PACKFILE *f, word s_version)
11231 {
11232 207 subscreens_active.clear();
11233 207 subscreens_passive.clear();
11234 207 subscreens_overlay.clear();
11235
2/2
✓ Branch 0 taken 26496 times.
✓ Branch 1 taken 207 times.
26703 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11236 {
11237 subscreen_group g;
11238 26496 memset(&g,0,sizeof(subscreen_group));
11239 26496 int32_t ret = read_one_old_subscreen(f, &g, s_version);
11240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26496 times.
26496 if(ret!=0)
11241 return ret;
11242
2/2
✓ Branch 0 taken 1074 times.
✓ Branch 1 taken 25422 times.
26496 if(g.objects[0].type == ssoNULL) continue;
11243
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 624 times.
1074 auto& vec = g.ss_type == sstPASSIVE ? subscreens_passive : subscreens_active;
11244 1074 ZCSubscreen& sub = vec.emplace_back();
11245 1074 sub.load_old(g);
11246 1074 }
11247
11248 207 return 0;
11249 207 }
11250
11251 26496 int32_t read_one_old_subscreen(PACKFILE *f, subscreen_group* g, word s_version)
11252 {
11253 26496 int32_t numsub=0;
11254 26496 byte temp_ss=0;
11255 subscreen_object temp_sub_stack;
11256 26496 subscreen_object *temp_sub = &temp_sub_stack;
11257
11258 char tempname[64];
11259
11260 // FWIW I never saw anything bigger than 20.
11261 #define MAX_DP1_LEN 1024
11262 char tempdp1[MAX_DP1_LEN];
11263
11264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26496 times.
26496 if(!pfread(tempname,64,f))
11265 {
11266 return qe_invalid;
11267 }
11268
11269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26496 times.
26496 if(s_version > 1)
11270 {
11271
1/2
✓ Branch 0 taken 26496 times.
✗ Branch 1 not taken.
26496 if(!p_getc(&temp_ss,f))
11272 {
11273 return qe_invalid;
11274 }
11275 26496 }
11276
11277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26496 times.
26496 if(s_version < 4)
11278 {
11279 uint8_t tmp=0;
11280
11281 if(!p_getc(&tmp,f))
11282 {
11283 return qe_invalid;
11284 }
11285
11286 numsub = (int32_t)tmp;
11287 }
11288 else
11289 {
11290 word tmp;
11291
11292
1/2
✓ Branch 0 taken 26496 times.
✗ Branch 1 not taken.
26496 if(!p_igetw(&tmp, f))
11293 {
11294 return qe_invalid;
11295 }
11296
11297 26496 numsub = (int32_t)tmp;
11298 }
11299
11300 int32_t j;
11301
11302
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 69602 times.
✓ Branch 2 taken 43106 times.
✓ Branch 3 taken 26496 times.
69602 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11303 {
11304 43106 memset(temp_sub,0,sizeof(subscreen_object));
11305
11306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43106 times.
43106 switch(g->objects[j].type)
11307 {
11308 case ssoTEXT:
11309 case ssoTEXTBOX:
11310 case ssoCURRENTITEMTEXT:
11311 case ssoCURRENTITEMCLASSTEXT:
11312 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11313
11314 //fall through
11315 default:
11316 43106 memset(&g->objects[j],0,sizeof(subscreen_object));
11317 43106 break;
11318 }
11319
11320
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_getc(&(temp_sub->type),f))
11321 return qe_invalid;
11322
11323
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_getc(&(temp_sub->pos),f))
11324 return qe_invalid;
11325
11326
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(s_version < 5)
11327 {
11328 switch(temp_sub->pos)
11329 {
11330 case 0:
11331 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11332 break;
11333
11334 case 1:
11335 temp_sub->pos = sspUP;
11336 break;
11337
11338 case 2:
11339 temp_sub->pos = sspDOWN;
11340 break;
11341
11342 default:
11343 temp_sub->pos = 0;
11344 }
11345 }
11346
11347
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetw(&(temp_sub->x),f))
11348 return qe_invalid;
11349
11350
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetw(&(temp_sub->y),f))
11351 return qe_invalid;
11352
11353
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetw(&(temp_sub->w),f))
11354 return qe_invalid;
11355
11356
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetw(&(temp_sub->h),f))
11357 return qe_invalid;
11358
11359
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_getc(&(temp_sub->colortype1),f))
11360 return qe_invalid;
11361
11362
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetw(&(temp_sub->color1),f))
11363 return qe_invalid;
11364
11365
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_getc(&(temp_sub->colortype2),f))
11366 return qe_invalid;
11367
11368
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetw(&(temp_sub->color2),f))
11369 return qe_invalid;
11370
11371
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_getc(&(temp_sub->colortype3),f))
11372 return qe_invalid;
11373
11374
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetw(&(temp_sub->color3),f))
11375 return qe_invalid;
11376
11377
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetd(&(temp_sub->d1),f))
11378 return qe_invalid;
11379
11380
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetd(&(temp_sub->d2),f))
11381 return qe_invalid;
11382
11383
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetd(&(temp_sub->d3),f))
11384 return qe_invalid;
11385
11386
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetd(&(temp_sub->d4),f))
11387 return qe_invalid;
11388
11389
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetd(&(temp_sub->d5),f))
11390 return qe_invalid;
11391
11392
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetd(&(temp_sub->d6),f))
11393 return qe_invalid;
11394
11395
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetd(&(temp_sub->d7),f))
11396 return qe_invalid;
11397
11398
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetd(&(temp_sub->d8),f))
11399 return qe_invalid;
11400
11401
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetd(&(temp_sub->d9),f))
11402 return qe_invalid;
11403
11404
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetd(&(temp_sub->d10),f))
11405 return qe_invalid;
11406
11407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43106 times.
43106 if(s_version < 2)
11408 {
11409 if(!p_igetl(&(temp_sub->speed),f))
11410 return qe_invalid;
11411
11412 if(!p_igetl(&(temp_sub->delay),f))
11413 return qe_invalid;
11414
11415 if(!p_igetl(&(temp_sub->frame),f))
11416 return qe_invalid;
11417 }
11418 else
11419 {
11420
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_getc(&(temp_sub->speed),f))
11421 return qe_invalid;
11422
11423
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_getc(&(temp_sub->delay),f))
11424 return qe_invalid;
11425
11426
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetw(&(temp_sub->frame),f))
11427 return qe_invalid;
11428 }
11429
11430 43106 int32_t temp_size=0;
11431
11432 // bool deletets = false;
11433
4/4
✓ Branch 0 taken 18992 times.
✓ Branch 1 taken 3250 times.
✓ Branch 2 taken 20648 times.
✓ Branch 3 taken 216 times.
43106 switch(temp_sub->type)
11434 {
11435 case ssoTEXT:
11436 case ssoTEXTBOX:
11437 case ssoCURRENTITEMTEXT:
11438 case ssoCURRENTITEMCLASSTEXT:
11439 {
11440 word temptempsize;
11441
11442
1/2
✓ Branch 0 taken 3250 times.
✗ Branch 1 not taken.
3250 if(!p_igetw(&temptempsize,f))
11443 {
11444 return qe_invalid;
11445 }
11446
11447 //temptempsize = temp1 + (temp2 << 8);
11448 3250 temp_size = (int32_t)temptempsize;
11449 3250 uint32_t char_length = temp_size+2;
11450
1/2
✓ Branch 0 taken 3250 times.
✗ Branch 1 not taken.
3250 if (char_length > MAX_DP1_LEN)
11451 {
11452 return qe_invalid;
11453 }
11454 3250 tempdp1[char_length - 1] = '\0';
11455
11456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3250 times.
3250 if(temp_size)
11457
1/2
✓ Branch 0 taken 3250 times.
✗ Branch 1 not taken.
3250 if(!pfread(tempdp1,temp_size+1,f))
11458 return qe_invalid;
11459 3250 break;
11460 }
11461
11462 case ssoLIFEMETER:
11463
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11464 temp_sub->d3 = 1;
11465
11466
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if(!p_getc(&(temp_sub->dp1),f))
11467 return qe_invalid;
11468
11469 216 break;
11470
11471
11472 case ssoCURRENTITEM:
11473
11474
1/2
✓ Branch 0 taken 18992 times.
✗ Branch 1 not taken.
18992 if(s_version < 6)
11475 {
11476 switch(temp_sub->d1)
11477 {
11478 case ssiBOMB:
11479 temp_sub->d1 = itype_bomb;
11480 break;
11481
11482 case ssiSWORD:
11483 temp_sub->d1 = itype_sword;
11484 break;
11485
11486 case ssiSHIELD:
11487 temp_sub->d1 = itype_shield;
11488 break;
11489
11490 case ssiCANDLE:
11491 temp_sub->d1 = itype_candle;
11492 break;
11493
11494 case ssiLETTER:
11495 temp_sub->d1 = itype_letter;
11496 break;
11497
11498 case ssiPOTION:
11499 temp_sub->d1 = itype_potion;
11500 break;
11501
11502 case ssiLETTERPOTION:
11503 temp_sub->d1 = itype_letterpotion;
11504 break;
11505
11506 case ssiBOW:
11507 temp_sub->d1 = itype_bow;
11508 break;
11509
11510 case ssiARROW:
11511 temp_sub->d1 = itype_arrow;
11512 break;
11513
11514 case ssiBOWANDARROW:
11515 temp_sub->d1 = itype_bowandarrow;
11516 break;
11517
11518 case ssiBAIT:
11519 temp_sub->d1 = itype_bait;
11520 break;
11521
11522 case ssiRING:
11523 temp_sub->d1 = itype_ring;
11524 break;
11525
11526 case ssiBRACELET:
11527 temp_sub->d1 = itype_bracelet;
11528 break;
11529
11530 case ssiMAP:
11531 temp_sub->d1 = itype_map;
11532 break;
11533
11534 case ssiCOMPASS:
11535 temp_sub->d1 = itype_compass;
11536 break;
11537
11538 case ssiBOSSKEY:
11539 temp_sub->d1 = itype_bosskey;
11540 break;
11541
11542 case ssiMAGICKEY:
11543 temp_sub->d1 = itype_magickey;
11544 break;
11545
11546 case ssiBRANG:
11547 temp_sub->d1 = itype_brang;
11548 break;
11549
11550 case ssiWAND:
11551 temp_sub->d1 = itype_wand;
11552 break;
11553
11554 case ssiRAFT:
11555 temp_sub->d1 = itype_raft;
11556 break;
11557
11558 case ssiLADDER:
11559 temp_sub->d1 = itype_ladder;
11560 break;
11561
11562 case ssiWHISTLE:
11563 temp_sub->d1 = itype_whistle;
11564 break;
11565
11566 case ssiBOOK:
11567 temp_sub->d1 = itype_book;
11568 break;
11569
11570 case ssiWALLET:
11571 temp_sub->d1 = itype_wallet;
11572 break;
11573
11574 case ssiSBOMB:
11575 temp_sub->d1 = itype_sbomb;
11576 break;
11577
11578 case ssiHCPIECE:
11579 temp_sub->d1 = itype_heartpiece;
11580 break;
11581
11582 case ssiAMULET:
11583 temp_sub->d1 = itype_amulet;
11584 break;
11585
11586 case ssiFLIPPERS:
11587 temp_sub->d1 = itype_flippers;
11588 break;
11589
11590 case ssiHOOKSHOT:
11591 temp_sub->d1 = itype_hookshot;
11592 break;
11593
11594 case ssiLENS:
11595 temp_sub->d1 = itype_lens;
11596 break;
11597
11598 case ssiHAMMER:
11599 temp_sub->d1 = itype_hammer;
11600 break;
11601
11602 case ssiBOOTS:
11603 temp_sub->d1 = itype_boots;
11604 break;
11605
11606 case ssiDIVINEFIRE:
11607 temp_sub->d1 = itype_divinefire;
11608 break;
11609
11610 case ssiDIVINEESCAPE:
11611 temp_sub->d1 = itype_divineescape;
11612 break;
11613
11614 case ssiDIVINEPROTECTION:
11615 temp_sub->d1 = itype_divineprotection;
11616 break;
11617
11618 case ssiQUIVER:
11619 temp_sub->d1 = itype_quiver;
11620 break;
11621
11622 case ssiBOMBBAG:
11623 temp_sub->d1 = itype_bombbag;
11624 break;
11625
11626 case ssiCBYRNA:
11627 temp_sub->d1 = itype_cbyrna;
11628 break;
11629
11630 case ssiROCS:
11631 temp_sub->d1 = itype_rocs;
11632 break;
11633
11634 case ssiHOVERBOOTS:
11635 temp_sub->d1 = itype_hoverboots;
11636 break;
11637
11638 case ssiSPINSCROLL:
11639 temp_sub->d1 = itype_spinscroll;
11640 break;
11641
11642 case ssiCROSSSCROLL:
11643 temp_sub->d1 = itype_crossscroll;
11644 break;
11645
11646 case ssiQUAKESCROLL:
11647 temp_sub->d1 = itype_quakescroll;
11648 break;
11649
11650 case ssiWHISPRING:
11651 temp_sub->d1 = itype_whispring;
11652 break;
11653
11654 case ssiCHARGERING:
11655 temp_sub->d1 = itype_chargering;
11656 break;
11657
11658 case ssiPERILSCROLL:
11659 temp_sub->d1 = itype_perilscroll;
11660 break;
11661
11662 case ssiWEALTHMEDAL:
11663 temp_sub->d1 = itype_wealthmedal;
11664 break;
11665
11666 case ssiHEARTRING:
11667 temp_sub->d1 = itype_heartring;
11668 break;
11669
11670 case ssiMAGICRING:
11671 temp_sub->d1 = itype_magicring;
11672 break;
11673
11674 case ssiSPINSCROLL2:
11675 temp_sub->d1 = itype_spinscroll2;
11676 break;
11677
11678 case ssiQUAKESCROLL2:
11679 temp_sub->d1 = itype_quakescroll2;
11680 break;
11681
11682 case ssiAGONY:
11683 temp_sub->d1 = itype_agony;
11684 break;
11685
11686 case ssiSTOMPBOOTS:
11687 temp_sub->d1 = itype_stompboots;
11688 break;
11689
11690 case ssiWHIMSICALRING:
11691 temp_sub->d1 = itype_whimsicalring;
11692 break;
11693
11694 case ssiPERILRING:
11695 temp_sub->d1 = itype_perilring;
11696 break;
11697
11698 default:
11699 temp_sub->d1 += itype_custom1 - ssiMAX;
11700 }
11701 }
11702
11703 //fall-through
11704 default:
11705
1/2
✓ Branch 0 taken 39640 times.
✗ Branch 1 not taken.
39640 if(!p_getc(&(temp_sub->dp1),f))
11706 return qe_invalid;
11707
11708 39640 break;
11709 }
11710
11711
2/2
✓ Branch 0 taken 9237 times.
✓ Branch 1 taken 33869 times.
43106 if(s_version < 7)
11712 {
11713
3/3
✓ Branch 0 taken 27879 times.
✓ Branch 1 taken 1366 times.
✓ Branch 2 taken 4624 times.
33869 switch(temp_sub->type)
11714 {
11715 case ssoMAGICGAUGE:
11716 {
11717
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 1248 times.
1366 if(!temp_sub->d9)
11718 1248 temp_sub->d9 = -1; //-1 now represents 'always'
11719 1366 break;
11720 }
11721 case ssoLIFEGAUGE:
11722 4624 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11723 4624 break;
11724 }
11725 33869 }
11726
11727
3/3
✓ Branch 0 taken 3250 times.
✓ Branch 1 taken 38354 times.
✓ Branch 2 taken 1502 times.
43106 switch(temp_sub->type)
11728 {
11729 case ssoTEXT:
11730 case ssoTEXTBOX:
11731 case ssoCURRENTITEMTEXT:
11732 case ssoCURRENTITEMCLASSTEXT:
11733
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3250 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3250 if(g->objects[j].dp1 != NULL) delete[](char *)g->objects[j].dp1;
11734
11735 3250 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11736 3250 g->objects[j].dp1 = new char[temp_size+2];
11737 3250 strcpy((char*)g->objects[j].dp1,tempdp1);
11738 3250 break;
11739
11740 case ssoCOUNTER:
11741
1/2
✓ Branch 0 taken 1502 times.
✗ Branch 1 not taken.
1502 if(s_version<3)
11742 {
11743 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11744 temp_sub->d8=0;
11745 }
11746
11747 default:
11748 39856 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11749 39856 break;
11750 }
11751
11752 43106 g->name[0] = '\0';
11753 43106 strncat(g->name, tempname, 64 - 1);
11754 43106 g->ss_type = temp_ss;
11755 43106 }
11756
11757
2/2
✓ Branch 0 taken 6739870 times.
✓ Branch 1 taken 26496 times.
6766366 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11758 {
11759 //clear all unused object in this subscreen -DD
11760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6739870 times.
6739870 switch(g->objects[j].type)
11761 {
11762 case ssoTEXT:
11763 case ssoTEXTBOX:
11764 case ssoCURRENTITEMTEXT:
11765 case ssoCURRENTITEMCLASSTEXT:
11766 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11767
11768 //fall through
11769 default:
11770 6739870 memset(&g->objects[j],0,sizeof(subscreen_object));
11771 6739870 break;
11772 }
11773 6739870 }
11774
11775 26496 return 0;
11776 26496 }
11777
11778 610 int32_t readsubscreens(PACKFILE *f)
11779 {
11780 word s_version, s_cversion;
11781 dword dummy;
11782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if(!p_igetw(&s_version,f))
11783 return qe_invalid;
11784 610 FFCore.quest_format[vSubscreen] = s_version;
11785
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_igetw(&s_cversion,f))
11786 return qe_invalid;
11787
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_igetl(&dummy,f)) //section size
11788 return qe_invalid;
11789
11790
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 403 times.
610 if(s_version < 8)
11791 207 return read_old_subscreens(f,s_version);
11792
11793 403 subscreens_active.clear();
11794 403 subscreens_passive.clear();
11795 403 subscreens_overlay.clear();
11796
11797 byte sz;
11798
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(!p_getc(&sz,f))
11799 return qe_invalid;
11800
2/2
✓ Branch 0 taken 772 times.
✓ Branch 1 taken 403 times.
1175 for(byte q = 0; q < sz; ++q)
11801 {
11802 772 ZCSubscreen& tmp = subscreens_active.emplace_back();
11803
1/2
✓ Branch 0 taken 772 times.
✗ Branch 1 not taken.
772 if (auto ret = tmp.read(f, s_version))
11804 return ret;
11805 772 }
11806
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(!p_getc(&sz,f))
11807 return qe_invalid;
11808
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 403 times.
1979 for(byte q = 0; q < sz; ++q)
11809 {
11810 1576 ZCSubscreen& tmp = subscreens_passive.emplace_back();
11811
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 if (auto ret = tmp.read(f, s_version))
11812 return ret;
11813 1576 }
11814
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(!p_getc(&sz,f))
11815 return qe_invalid;
11816
2/2
✓ Branch 0 taken 550 times.
✓ Branch 1 taken 403 times.
953 for(byte q = 0; q < sz; ++q)
11817 {
11818 550 ZCSubscreen& tmp = subscreens_overlay.emplace_back();
11819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550 times.
550 if (auto ret = tmp.read(f, s_version))
11820 return ret;
11821 550 }
11822 403 return 0;
11823 610 }
11824
11825 void reset_subscreen(subscreen_group *tempss)
11826 {
11827 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11828 {
11829 switch(tempss->objects[i].type)
11830 {
11831 case ssoTEXT:
11832 case ssoTEXTBOX:
11833 case ssoCURRENTITEMTEXT:
11834 case ssoCURRENTITEMCLASSTEXT:
11835 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11836
11837 //fall through
11838 default:
11839 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11840 break;
11841 }
11842 }
11843 }
11844
11845 107 void reset_subscreens()
11846 {
11847 107 subscreens_active.clear();
11848 107 subscreens_passive.clear();
11849 107 subscreens_overlay.clear();
11850 107 }
11851
11852 107 int32_t setupsubscreens()
11853 {
11854 107 reset_subscreens();
11855 //return 0;
11856
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 214 times.
321 for(int q = 0; q < 2; ++q)
11857 {
11858 214 subscreens_active.emplace_back();
11859 214 subscreens_passive.emplace_back();
11860 214 }
11861 107 int32_t tempsubscreen=subscr_mode;
11862
11863
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(tempsubscreen>=ssdtMAX)
11864 tempsubscreen=0;
11865
11866
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
✗ Branch 2 not taken.
107 switch(tempsubscreen)
11867 {
11868 case ssdtOLD:
11869 case ssdtNEWSUBSCR:
11870 case ssdtREV2:
11871 case ssdtBSZELDA:
11872 case ssdtBSZELDAMODIFIED:
11873 case ssdtBSZELDAENHANCED:
11874 case ssdtBSZELDACOMPLETE:
11875 {
11876 107 subscreens_active[0].load_old(default_subscreen_active[tempsubscreen][0]);
11877 107 subscreens_active[0].sub_type=sstACTIVE;
11878 107 subscreens_active[0].name = "Active Subscreen (Triforce)";
11879 107 subscreens_active[1].load_old(default_subscreen_active[tempsubscreen][1]);
11880 107 subscreens_active[1].sub_type=sstACTIVE;
11881 107 subscreens_active[1].name = "Active Subscreen (Dungeon Map)";
11882 107 subscreens_passive[0].load_old(default_subscreen_passive[tempsubscreen][0]);
11883 107 subscreens_passive[0].sub_type=sstPASSIVE;
11884 107 subscreens_passive[0].name = "Passive Subscreen (Magic)";
11885 107 subscreens_passive[1].load_old(default_subscreen_passive[tempsubscreen][1]);
11886 107 subscreens_passive[1].sub_type=sstPASSIVE;
11887 107 subscreens_passive[1].name = "Passive Subscreen (No Magic)";
11888 107 break;
11889 }
11890
11891 case ssdtZ3:
11892 {
11893 subscreens_active[0].load_old(z3_active_a);
11894 subscreens_active[0].sub_type=sstACTIVE;
11895 subscreens_active[1].load_old(z3_active_ab);
11896 subscreens_active[1].sub_type=sstACTIVE;
11897 subscreens_passive[0].load_old(z3_passive_a);
11898 subscreens_passive[0].sub_type=sstPASSIVE;
11899 subscreens_passive[1].load_old(z3_passive_ab);
11900 subscreens_passive[1].sub_type=sstPASSIVE;
11901 break;
11902 }
11903 }
11904 107 subscr_mode = ssdtMAX;
11905 107 return 0;
11906 }
11907
11908 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
11909
11910 extern script_data *ffscripts[NUMSCRIPTFFC];
11911 extern script_data *itemscripts[NUMSCRIPTITEM];
11912 extern script_data *guyscripts[NUMSCRIPTGUYS];
11913 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
11914 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
11915 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
11916 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
11917 extern script_data *playerscripts[NUMSCRIPTPLAYER];
11918 extern script_data *screenscripts[NUMSCRIPTSCREEN];
11919 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
11920 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
11921 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
11922 extern script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
11923
11924 static std::vector<const script_data*> read_scripts;
11925
11926 1080 int32_t readffscript(PACKFILE *f, zquestheader *Header)
11927 {
11928 int32_t dummy;
11929 1080 word s_version=0, s_cversion=0, zmeta_version=0;
11930 1080 byte numscripts=0;
11931 1080 numscripts=numscripts; //to avoid unused variables warnings
11932 int32_t ret;
11933 1080 read_scripts.clear();
11934 1080 zasm_scripts.clear();
11935
11936 //section version info
11937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1080 times.
1080 if(!p_igetw(&s_version,f))
11938 {
11939 return qe_invalid;
11940 }
11941
11942 1080 FFCore.quest_format[vFFScript] = s_version;
11943
11944
1/2
✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
1080 if(!p_igetw(&s_cversion,f))
11945 {
11946 return qe_invalid;
11947 }
11948
11949
2/2
✓ Branch 0 taken 659 times.
✓ Branch 1 taken 421 times.
1080 if(s_version >= 18)
11950 {
11951
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_igetw(&zmeta_version,f))
11952 {
11953 return qe_invalid;
11954 }
11955 421 }
11956
11957 //section size
11958
1/2
✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
1080 if(!p_igetl(&dummy,f))
11959 {
11960 return qe_invalid;
11961 }
11962
11963
2/2
✓ Branch 0 taken 873 times.
✓ Branch 1 taken 207 times.
1080 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
11964 1080 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
11965
11966 //finally... section data
11967
2/2
✓ Branch 0 taken 312320 times.
✓ Branch 1 taken 1074 times.
313400 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
11968 {
11969 312320 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
11970
11971
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if (ret)
11972 {
11973 return qe_invalid;
11974 }
11975 312320 }
11976
11977 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
11978 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
11979 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
11980 * there was a version bump a week before a change that broke stuff.
11981 */
11982
7/8
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 653 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 421 times.
✓ Branch 4 taken 421 times.
✓ Branch 5 taken 421 times.
✓ Branch 6 taken 421 times.
✓ Branch 7 taken 421 times.
1074 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)))
11983 {
11984 1495 set_qr(qr_SPRITE_JUMP_IS_TRUNCATED,1);
11985 1495 }
11986
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 189 times.
610 if(s_version < 19)
11987 {
11988 189 set_qr(qr_FLUCTUATING_ENEMY_JUMP,1);
11989 189 }
11990
11991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if(s_version > 1)
11992 {
11993
2/2
✓ Branch 0 taken 156160 times.
✓ Branch 1 taken 610 times.
156770 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
11994 {
11995 156160 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
11996
11997
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if (ret)
11998 {
11999 return qe_invalid;
12000 }
12001 156160 }
12002
12003
2/2
✓ Branch 0 taken 156160 times.
✓ Branch 1 taken 610 times.
156770 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12004 {
12005 156160 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
12006
12007
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if (ret)
12008 {
12009 return qe_invalid;
12010 }
12011 156160 }
12012
12013
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 script_data *fake = new script_data(ScriptType::None, 0);
12014
2/2
✓ Branch 0 taken 156160 times.
✓ Branch 1 taken 610 times.
156770 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12015 {
12016 156160 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &fake, zmeta_version);
12017
12018
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if (ret)
12019 {
12020 return qe_invalid;
12021 }
12022 156160 }
12023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 delete fake;
12024
12025
2/2
✓ Branch 0 taken 156160 times.
✓ Branch 1 taken 610 times.
156770 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12026 {
12027 156160 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12028
12029
1/2
✓ Branch 0 taken 156160 times.
✗ Branch 1 not taken.
156160 if (ret)
12030 {
12031 return qe_invalid;
12032 }
12033 156160 }
12034
12035
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 189 times.
610 if(s_version > 16)
12036 {
12037
2/2
✓ Branch 0 taken 3368 times.
✓ Branch 1 taken 421 times.
3789 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12038 {
12039 3368 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12040
12041
1/2
✓ Branch 0 taken 3368 times.
✗ Branch 1 not taken.
3368 if (ret)
12042 {
12043 return qe_invalid;
12044 }
12045 3368 }
12046 421 }
12047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 else if(s_version > 13)
12048 {
12049 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12050 {
12051 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12052
12053 if (ret)
12054 {
12055 return qe_invalid;
12056 }
12057 }
12058
12059 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12060 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12061
12062 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12063 }
12064
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 else if(s_version > 4)
12065 {
12066
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 189 times.
945 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12067 {
12068 756 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12069
12070
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if (ret)
12071 {
12072 return qe_invalid;
12073 }
12074 756 }
12075
12076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12077
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12078
12079
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12080
12081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12082
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12083
12084
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12085
12086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12087
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 delete globalscripts[GLOBAL_SCRIPT_F6];
12088
12089
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12090
12091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12092
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12093
12094
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12095 189 }
12096 else
12097 {
12098 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12099 {
12100 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12101
12102 if (ret)
12103 {
12104 return qe_invalid;
12105 }
12106 }
12107
12108 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12109 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12110
12111 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVELOAD);
12112
12113 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12114 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12115
12116 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12117
12118 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12119 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12120
12121 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12122
12123 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12124 delete globalscripts[GLOBAL_SCRIPT_F6];
12125
12126 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12127
12128 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12129 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12130
12131 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12132 }
12133
12134
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 189 times.
610 if(s_version > 10) //expanded the number of Player scripts to 5.
12135 {
12136
2/2
✓ Branch 0 taken 2105 times.
✓ Branch 1 taken 421 times.
2526 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12137 {
12138 2105 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12139
12140
1/2
✓ Branch 0 taken 2105 times.
✗ Branch 1 not taken.
2105 if (ret)
12141 {
12142 return qe_invalid;
12143 }
12144 2105 }
12145 421 }
12146 else
12147 {
12148
2/2
✓ Branch 0 taken 567 times.
✓ Branch 1 taken 189 times.
756 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12149 {
12150 567 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12151
12152
1/2
✓ Branch 0 taken 567 times.
✗ Branch 1 not taken.
567 if (ret)
12153 {
12154 return qe_invalid;
12155 }
12156 567 }
12157
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(playerscripts[3] != NULL)
12158
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 delete playerscripts[3];
12159
12160
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 playerscripts[3] = new script_data(ScriptType::Player, 3);
12161
12162
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(playerscripts[4] != NULL)
12163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 delete playerscripts[4];
12164
12165
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 playerscripts[4] = new script_data(ScriptType::Player, 4);
12166 }
12167
3/4
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 189 times.
✓ Branch 2 taken 421 times.
✗ Branch 3 not taken.
610 if(s_version > 8 && s_version < 10)
12168 {
12169
12170 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12171 {
12172 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12173
12174 if (ret)
12175 {
12176 return qe_invalid;
12177 }
12178 }
12179 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12180 {
12181 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12182
12183 if (ret)
12184 {
12185 return qe_invalid;
12186 }
12187 }
12188
12189 }
12190
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 421 times.
610 if(s_version >= 10)
12191 {
12192
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 421 times.
108197 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12193 {
12194 107776 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12195
12196
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if (ret)
12197 {
12198 return qe_invalid;
12199 }
12200 107776 }
12201
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 421 times.
108197 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12202 {
12203 107776 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12204
12205
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if (ret)
12206 {
12207 return qe_invalid;
12208 }
12209 107776 }
12210
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 421 times.
108197 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12211 {
12212 107776 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12213
12214
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if (ret)
12215 {
12216 return qe_invalid;
12217 }
12218 107776 }
12219
12220 421 }
12221
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 421 times.
610 if(s_version >=12)
12222 {
12223
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 421 times.
108197 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12224 {
12225 107776 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12226
12227
1/2
✓ Branch 0 taken 107776 times.
✗ Branch 1 not taken.
107776 if (ret)
12228 {
12229 return qe_invalid;
12230 }
12231 107776 }
12232 421 }
12233
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 421 times.
610 if(s_version >=15)
12234 {
12235
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 421 times.
215973 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12236 {
12237 215552 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12238
12239
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if (ret)
12240 {
12241 return qe_invalid;
12242 }
12243 215552 }
12244 421 }
12245
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 421 times.
610 if(s_version >19)
12246 {
12247 421 word numgenscripts = NUMSCRIPTSGENERIC;
12248
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_igetw(&numgenscripts,f))
12249 {
12250 return qe_invalid;
12251 }
12252
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 421 times.
215973 for(int32_t i = 0; i < numgenscripts; i++)
12253 {
12254 215552 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12255
12256
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if (ret)
12257 {
12258 return qe_invalid;
12259 }
12260 215552 }
12261 421 }
12262
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 403 times.
610 if(s_version >21)
12263 {
12264 403 word numsubscripts = NUMSCRIPTSSUBSCREEN;
12265
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(!p_igetw(&numsubscripts,f))
12266 {
12267 return qe_invalid;
12268 }
12269
2/2
✓ Branch 0 taken 103168 times.
✓ Branch 1 taken 403 times.
103571 for(int32_t i = 0; i < numsubscripts; i++)
12270 {
12271 103168 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &subscreenscripts[i], zmeta_version);
12272
12273
1/2
✓ Branch 0 taken 103168 times.
✗ Branch 1 not taken.
103168 if (ret)
12274 {
12275 return qe_invalid;
12276 }
12277 103168 }
12278 403 }
12279 610 }
12280
12281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if(s_version > 2)
12282 {
12283 int32_t bufsize;
12284 610 p_igetl(&bufsize, f);
12285
2/4
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 610 times.
610 if (bufsize < 0 || bufsize > 1024*1024*10)
12286 {
12287 // God help anyone storing more than 10MB of code in the script buffer.
12288 return qe_invalid;
12289 }
12290 610 char * buf = new char[bufsize+1];
12291 610 pfread(buf, bufsize, f);
12292 610 buf[bufsize]=0;
12293
12294
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 zScript = string(buf);
12295
12296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 delete[] buf;
12297 word numffcbindings;
12298 610 p_igetw(&numffcbindings, f);
12299
12300
2/2
✓ Branch 0 taken 9649 times.
✓ Branch 1 taken 610 times.
10259 for(int32_t i=0; i<numffcbindings; i++)
12301 {
12302 word id;
12303 9649 p_igetw(&id, f);
12304 9649 p_igetl(&bufsize, f);
12305
2/4
✓ Branch 0 taken 9649 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9649 times.
9649 if (bufsize < 0 || bufsize > 1024)
12306 return qe_invalid;
12307 9649 buf = new char[bufsize+1];
12308 9649 pfread(buf, bufsize, f);
12309 9649 buf[bufsize]=0;
12310
12311 //fix for buggy older saved quests -DD
12312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9649 times.
9649 if(id < NUMSCRIPTFFC-1)
12313 9649 ffcmap[id].scriptname = buf;
12314
12315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9649 times.
9649 delete[] buf;
12316 9649 }
12317
12318 word numglobalbindings;
12319 610 p_igetw(&numglobalbindings, f);
12320
12321
2/2
✓ Branch 0 taken 1755 times.
✓ Branch 1 taken 610 times.
2365 for(int32_t i=0; i<numglobalbindings; i++)
12322 {
12323 word id;
12324 1755 p_igetw(&id, f);
12325 1755 p_igetl(&bufsize, f);
12326
2/4
✓ Branch 0 taken 1755 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1755 times.
✗ Branch 3 not taken.
1755 if (bufsize < 0 || bufsize > 1024)
12327 return qe_invalid;
12328 1755 buf = new char[bufsize+1];
12329 1755 pfread(buf, bufsize, f);
12330 1755 buf[bufsize]=0;
12331
12332 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12333 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12334 // Ignore these. -DD
12335
2/2
✓ Branch 0 taken 540 times.
✓ Branch 1 taken 1215 times.
1755 if (id < NUMSCRIPTGLOBAL)
12336 {
12337 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12338
1/2
✓ Branch 0 taken 1215 times.
✗ Branch 1 not taken.
1215 if(strcmp(buf,"~Continue") == 0)
12339 {
12340 globalmap[id].scriptname = "";
12341
12342 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12343 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12344 }
12345 else
12346 {
12347 1215 globalmap[id].scriptname = buf;
12348 }
12349 1215 }
12350
12351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1755 times.
1755 delete[] buf;
12352 1755 }
12353
12354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if(s_version > 3)
12355 {
12356 word numitembindings;
12357 610 p_igetw(&numitembindings, f);
12358
12359
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 610 times.
1762 for(int32_t i=0; i<numitembindings; i++)
12360 {
12361 word id;
12362 1152 p_igetw(&id, f);
12363 1152 p_igetl(&bufsize, f);
12364
2/4
✓ Branch 0 taken 1152 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1152 times.
1152 if (bufsize < 0 || bufsize > 1024)
12365 return qe_invalid;
12366 1152 buf = new char[bufsize+1];
12367 1152 pfread(buf, bufsize, f);
12368 1152 buf[bufsize]=0;
12369
12370 //fix this too
12371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1152 times.
1152 if(id <NUMSCRIPTITEM-1)
12372 1152 itemmap[id].scriptname = buf;
12373
12374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1152 times.
1152 delete[] buf;
12375 1152 }
12376 610 }
12377 //(v9+)
12378
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 421 times.
610 if(s_version > 8)
12379 {
12380 //npc scripts
12381 word numnpcbindings;
12382 421 p_igetw(&numnpcbindings, f);
12383
12384
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 421 times.
452 for(int32_t i=0; i<numnpcbindings; i++)
12385 {
12386 word id;
12387 31 p_igetw(&id, f);
12388 31 p_igetl(&bufsize, f);
12389
2/4
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
31 if (bufsize < 0 || bufsize > 1024)
12390 return qe_invalid;
12391 31 buf = new char[bufsize+1];
12392 31 pfread(buf, bufsize, f);
12393 31 buf[bufsize]=0;
12394
12395 //fix this too
12396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(id <NUMSCRIPTGUYS-1)
12397 31 npcmap[id].scriptname = buf;
12398
12399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 delete[] buf;
12400 31 }
12401 //lweapon
12402 word numlwpnbindings;
12403 421 p_igetw(&numlwpnbindings, f);
12404
12405
2/2
✓ Branch 0 taken 213 times.
✓ Branch 1 taken 421 times.
634 for(int32_t i=0; i<numlwpnbindings; i++)
12406 {
12407 word id;
12408 213 p_igetw(&id, f);
12409 213 p_igetl(&bufsize, f);
12410
2/4
✓ Branch 0 taken 213 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213 times.
✗ Branch 3 not taken.
213 if (bufsize < 0 || bufsize > 1024)
12411 return qe_invalid;
12412 213 buf = new char[bufsize+1];
12413 213 pfread(buf, bufsize, f);
12414 213 buf[bufsize]=0;
12415
12416 //fix this too
12417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 213 times.
213 if(id <NUMSCRIPTWEAPONS-1)
12418 213 lwpnmap[id].scriptname = buf;
12419
12420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 213 times.
213 delete[] buf;
12421 213 }
12422 //eweapon
12423 word numewpnbindings;
12424 421 p_igetw(&numewpnbindings, f);
12425
12426
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 421 times.
701 for(int32_t i=0; i<numewpnbindings; i++)
12427 {
12428 word id;
12429 280 p_igetw(&id, f);
12430 280 p_igetl(&bufsize, f);
12431
2/4
✓ Branch 0 taken 280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 280 times.
✗ Branch 3 not taken.
280 if (bufsize < 0 || bufsize > 1024)
12432 return qe_invalid;
12433 280 buf = new char[bufsize+1];
12434 280 pfread(buf, bufsize, f);
12435 280 buf[bufsize]=0;
12436
12437 //fix this too
12438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280 times.
280 if(id <NUMSCRIPTWEAPONS-1)
12439 280 ewpnmap[id].scriptname = buf;
12440
12441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280 times.
280 delete[] buf;
12442 280 }
12443 //hero
12444 word numherobindings;
12445 421 p_igetw(&numherobindings, f);
12446
12447
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 421 times.
442 for(int32_t i=0; i<numherobindings; i++)
12448 {
12449 word id;
12450 21 p_igetw(&id, f);
12451 21 p_igetl(&bufsize, f);
12452
2/4
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
21 if (bufsize < 0 || bufsize > 1024)
12453 return qe_invalid;
12454 21 buf = new char[bufsize+1];
12455 21 pfread(buf, bufsize, f);
12456 21 buf[bufsize]=0;
12457
12458 //fix this too
12459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if(id <NUMSCRIPTPLAYER-1)
12460 21 playermap[id].scriptname = buf;
12461
12462
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 delete[] buf;
12463 21 }
12464 //dmaps
12465 word numdmapbindings;
12466 421 p_igetw(&numdmapbindings, f);
12467
12468
2/2
✓ Branch 0 taken 253 times.
✓ Branch 1 taken 421 times.
674 for(int32_t i=0; i<numdmapbindings; i++)
12469 {
12470 word id;
12471 253 p_igetw(&id, f);
12472 253 p_igetl(&bufsize, f);
12473
2/4
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 253 times.
✗ Branch 3 not taken.
253 if (bufsize < 0 || bufsize > 1024)
12474 return qe_invalid;
12475 253 buf = new char[bufsize+1];
12476 253 pfread(buf, bufsize, f);
12477 253 buf[bufsize]=0;
12478
12479 //fix this too
12480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 253 times.
253 if(id <NUMSCRIPTSDMAP-1)
12481 253 dmapmap[id].scriptname = buf;
12482
12483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 253 times.
253 delete[] buf;
12484 253 }
12485 //screen
12486 word numscreenbindings;
12487 421 p_igetw(&numscreenbindings, f);
12488
12489
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 421 times.
753 for(int32_t i=0; i<numscreenbindings; i++)
12490 {
12491 word id;
12492 332 p_igetw(&id, f);
12493 332 p_igetl(&bufsize, f);
12494
2/4
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 332 times.
✗ Branch 3 not taken.
332 if (bufsize < 0 || bufsize > 1024)
12495 return qe_invalid;
12496 332 buf = new char[bufsize+1];
12497 332 pfread(buf, bufsize, f);
12498 332 buf[bufsize]=0;
12499
12500 //fix this too
12501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(id <NUMSCRIPTSDMAP-1)
12502 332 screenmap[id].scriptname = buf;
12503
12504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 delete[] buf;
12505 332 }
12506 421 }
12507
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 421 times.
610 if(s_version > 11)
12508 {
12509 word numspritebindings;
12510 421 p_igetw(&numspritebindings, f);
12511
12512
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 421 times.
465 for(int32_t i=0; i<numspritebindings; i++)
12513 {
12514 word id;
12515 44 p_igetw(&id, f);
12516 44 p_igetl(&bufsize, f);
12517
2/4
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 44 times.
✗ Branch 3 not taken.
44 if (bufsize < 0 || bufsize > 1024)
12518 return qe_invalid;
12519 44 buf = new char[bufsize+1];
12520 44 pfread(buf, bufsize, f);
12521 44 buf[bufsize]=0;
12522
12523 //fix this too
12524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(id <NUMSCRIPTSDMAP-1)
12525 44 itemspritemap[id].scriptname = buf;
12526
12527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 delete[] buf;
12528 44 }
12529 421 }
12530
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 421 times.
610 if(s_version >= 15)
12531 {
12532 word numcombobindings;
12533 421 p_igetw(&numcombobindings, f);
12534
12535
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 421 times.
564 for(int32_t i=0; i<numcombobindings; i++)
12536 {
12537 word id;
12538 143 p_igetw(&id, f);
12539 143 p_igetl(&bufsize, f);
12540
2/4
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 143 times.
143 if (bufsize < 0 || bufsize > 1024)
12541 return qe_invalid;
12542 143 buf = new char[bufsize+1];
12543 143 pfread(buf, bufsize, f);
12544 143 buf[bufsize]=0;
12545
12546 //fix this too
12547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
143 if(id <NUMSCRIPTSCOMBODATA-1)
12548 143 comboscriptmap[id].scriptname = buf;
12549
12550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
143 delete[] buf;
12551 143 }
12552 421 }
12553
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 421 times.
610 if(s_version > 19)
12554 {
12555 word numgenericbindings;
12556 421 p_igetw(&numgenericbindings, f);
12557
12558
2/2
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 421 times.
524 for(int32_t i=0; i<numgenericbindings; i++)
12559 {
12560 word id;
12561 103 p_igetw(&id, f);
12562 103 p_igetl(&bufsize, f);
12563
2/4
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 103 times.
103 if (bufsize < 0 || bufsize > 1024)
12564 return qe_invalid;
12565 103 buf = new char[bufsize+1];
12566 103 pfread(buf, bufsize, f);
12567 103 buf[bufsize]=0;
12568
12569 //fix this too
12570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 if(id <NUMSCRIPTSGENERIC-1)
12571 103 genericmap[id].scriptname = buf;
12572
12573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 delete[] buf;
12574 103 }
12575 421 }
12576
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 403 times.
610 if(s_version > 21)
12577 {
12578 word numsubscreenbindings;
12579 403 p_igetw(&numsubscreenbindings, f);
12580
12581
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 403 times.
410 for(int32_t i=0; i<numsubscreenbindings; i++)
12582 {
12583 word id;
12584 7 p_igetw(&id, f);
12585 7 p_igetl(&bufsize, f);
12586
2/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
7 if (bufsize < 0 || bufsize > 1024)
12587 return qe_invalid;
12588 7 buf = new char[bufsize+1];
12589 7 pfread(buf, bufsize, f);
12590 7 buf[bufsize]=0;
12591
12592 //fix this too
12593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(id <NUMSCRIPTSSUBSCREEN-1)
12594 7 subscreenmap[id].scriptname = buf;
12595
12596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 delete[] buf;
12597 7 }
12598 403 }
12599 610 }
12600
12601 // Set ZScriptVersion to the value encoded in the script's meta.ffscript_v.
12602 // This is only updated when the scripts have been recompiled.
12603 // They should all match each other.
12604 610 std::optional<word> zscript_version;
12605
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 421 times.
610 if (s_version >= 16)
12606 {
12607
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 for (auto script : read_scripts)
12608 {
12609 if (script->meta.ffscript_v == 0 || script->meta.ffscript_v > s_version)
12610 break;
12611
12612 if (!zscript_version.has_value())
12613 {
12614 zscript_version = script->meta.ffscript_v;
12615 continue;
12616 }
12617
12618 if (zscript_version.value() != script->meta.ffscript_v)
12619 {
12620 zscript_version.reset();
12621 break;
12622 }
12623 }
12624
12625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
421 if (!zscript_version.has_value())
12626 421 al_trace("WARNING: Setting zscript version to section version as fallback.\n");
12627 421 }
12628 610 setZScriptVersion(zscript_version.value_or(s_version));
12629 610 read_scripts.clear();
12630
12631 610 return 0;
12632 610 }
12633
12634 692 void reset_scripts()
12635 {
12636 #ifdef IS_PLAYER
12637 // We can't modify the script data while jit threads are possibly compiling them.
12638 void jit_shutdown();
12639 683 jit_shutdown();
12640 #endif
12641
12642
2/2
✓ Branch 0 taken 354304 times.
✓ Branch 1 taken 692 times.
354996 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12643 {
12644
1/2
✓ Branch 0 taken 354304 times.
✗ Branch 1 not taken.
354304 if (genericscripts[i]!=NULL) genericscripts[i]->disable();
12645 else genericscripts[i] = new script_data({ScriptType::Generic, i});
12646 354304 }
12647
12648
2/2
✓ Branch 0 taken 354304 times.
✓ Branch 1 taken 692 times.
354996 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12649 {
12650
1/2
✓ Branch 0 taken 354304 times.
✗ Branch 1 not taken.
354304 if (ffscripts[i])
12651 354304 ffscripts[i]->disable();
12652 else
12653 ffscripts[i] = new script_data(ScriptType::FFC, i);
12654 354304 }
12655
12656
2/2
✓ Branch 0 taken 177152 times.
✓ Branch 1 taken 692 times.
177844 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12657 {
12658
1/2
✓ Branch 0 taken 177152 times.
✗ Branch 1 not taken.
177152 if (itemscripts[i])
12659 177152 itemscripts[i]->disable();
12660 else
12661 itemscripts[i] = new script_data(ScriptType::Item, i);
12662 177152 }
12663
12664
2/2
✓ Branch 0 taken 177152 times.
✓ Branch 1 taken 692 times.
177844 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12665 {
12666
1/2
✓ Branch 0 taken 177152 times.
✗ Branch 1 not taken.
177152 if (guyscripts[i])
12667 177152 guyscripts[i]->disable();
12668 else
12669 guyscripts[i] = new script_data(ScriptType::NPC, i);
12670 177152 }
12671
12672
2/2
✓ Branch 0 taken 177152 times.
✓ Branch 1 taken 692 times.
177844 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12673 {
12674
1/2
✓ Branch 0 taken 177152 times.
✗ Branch 1 not taken.
177152 if (screenscripts[i])
12675 177152 screenscripts[i]->disable();
12676 else
12677 screenscripts[i] = new script_data(ScriptType::Screen, i);
12678 177152 }
12679
12680
2/2
✓ Branch 0 taken 5536 times.
✓ Branch 1 taken 692 times.
6228 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12681 {
12682
1/2
✓ Branch 0 taken 5536 times.
✗ Branch 1 not taken.
5536 if (globalscripts[i])
12683 5536 globalscripts[i]->disable();
12684 else
12685 globalscripts[i] = new script_data(ScriptType::Global, i);
12686 5536 }
12687
12688
2/2
✓ Branch 0 taken 3460 times.
✓ Branch 1 taken 692 times.
4152 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
12689 {
12690
1/2
✓ Branch 0 taken 3460 times.
✗ Branch 1 not taken.
3460 if (playerscripts[i])
12691 3460 playerscripts[i]->disable();
12692 else
12693 playerscripts[i] = new script_data(ScriptType::Player, i);
12694 3460 }
12695
12696
2/2
✓ Branch 0 taken 177152 times.
✓ Branch 1 taken 692 times.
177844 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12697 {
12698
1/2
✓ Branch 0 taken 177152 times.
✗ Branch 1 not taken.
177152 if (lwpnscripts[i])
12699 177152 lwpnscripts[i]->disable();
12700 else
12701 lwpnscripts[i] = new script_data(ScriptType::Lwpn, i);
12702 177152 }
12703
2/2
✓ Branch 0 taken 177152 times.
✓ Branch 1 taken 692 times.
177844 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12704 {
12705
1/2
✓ Branch 0 taken 177152 times.
✗ Branch 1 not taken.
177152 if (ewpnscripts[i])
12706 177152 ewpnscripts[i]->disable();
12707 else
12708 ewpnscripts[i] = new script_data(ScriptType::Ewpn, i);
12709 177152 }
12710
12711
2/2
✓ Branch 0 taken 177152 times.
✓ Branch 1 taken 692 times.
177844 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12712 {
12713
1/2
✓ Branch 0 taken 177152 times.
✗ Branch 1 not taken.
177152 if (dmapscripts[i])
12714 177152 dmapscripts[i]->disable();
12715 else
12716 dmapscripts[i] = new script_data(ScriptType::DMap, i);
12717 177152 }
12718
2/2
✓ Branch 0 taken 177152 times.
✓ Branch 1 taken 692 times.
177844 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12719 {
12720
1/2
✓ Branch 0 taken 177152 times.
✗ Branch 1 not taken.
177152 if (itemspritescripts[i])
12721 177152 itemspritescripts[i]->disable();
12722 else
12723 itemspritescripts[i] = new script_data(ScriptType::ItemSprite, i);
12724 177152 }
12725
2/2
✓ Branch 0 taken 354304 times.
✓ Branch 1 taken 692 times.
354996 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12726 {
12727
1/2
✓ Branch 0 taken 354304 times.
✗ Branch 1 not taken.
354304 if (comboscripts[i])
12728 354304 comboscripts[i]->disable();
12729 else
12730 comboscripts[i] = new script_data(ScriptType::Combo, i);
12731 354304 }
12732
2/2
✓ Branch 0 taken 177152 times.
✓ Branch 1 taken 692 times.
177844 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
12733 {
12734
1/2
✓ Branch 0 taken 177152 times.
✗ Branch 1 not taken.
177152 if (subscreenscripts[i])
12735 177152 subscreenscripts[i]->disable();
12736 else
12737 subscreenscripts[i] = new script_data(ScriptType::EngineSubscreen, i);
12738 177152 }
12739 692 }
12740
12741 1909132 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, int32_t script_index, word s_version, word , script_data **script, word zmeta_version)
12742 {
12743 // TODO: refactor to just take a script_data*
12744 ASSERT(*script);
12745
12746 //Please also update loadquest() when modifying this method -DD
12747 1909132 char b33[34] = {0};
12748 1909132 b33[33] = 0;
12749 1909132 int32_t num_commands=1000;
12750
12751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1909132 times.
1909132 if(s_version>=2)
12752 {
12753
1/2
✓ Branch 0 taken 1909132 times.
✗ Branch 1 not taken.
1909132 if(!p_igetl(&num_commands,f))
12754 {
12755 return qe_invalid;
12756 }
12757 1909132 }
12758
12759 #ifdef ZC_FUZZ
12760 const int32_t command_limit = 300000;
12761 #else
12762 1909132 const int32_t command_limit = 10000000;
12763 #endif
12764
2/4
✓ Branch 0 taken 1909132 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1909132 times.
1909132 if (num_commands < 0 || num_commands > command_limit)
12765 {
12766 return qe_invalid;
12767 }
12768
12769 1909132 std::vector<ffscript> zasm;
12770
1/2
✓ Branch 0 taken 1909132 times.
✗ Branch 1 not taken.
1909132 zasm.reserve(num_commands);
12771
12772
2/2
✓ Branch 0 taken 1617505 times.
✓ Branch 1 taken 291627 times.
1909132 if(s_version >= 16)
12773 {
12774
1/2
✓ Branch 0 taken 1617505 times.
✗ Branch 1 not taken.
1617505 zasm_meta temp_meta;
12775
12776
2/4
✓ Branch 0 taken 1617505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1617505 times.
✗ Branch 3 not taken.
1617505 if(!p_igetw(&(temp_meta.zasm_v),f))
12777 {
12778 return qe_invalid;
12779 }
12780
12781
2/4
✓ Branch 0 taken 1617505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1617505 times.
✗ Branch 3 not taken.
1617505 if(!p_igetw(&(temp_meta.meta_v),f))
12782 {
12783 return qe_invalid;
12784 }
12785
12786
2/4
✓ Branch 0 taken 1617505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1617505 times.
✗ Branch 3 not taken.
1617505 if(!p_igetw(&(temp_meta.ffscript_v),f))
12787 {
12788 return qe_invalid;
12789 }
12790
12791
2/4
✓ Branch 0 taken 1617505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1617505 times.
✗ Branch 3 not taken.
1617505 if(!p_getc(&(temp_meta.script_type),f))
12792 {
12793 return qe_invalid;
12794 }
12795
12796
2/2
✓ Branch 0 taken 12940040 times.
✓ Branch 1 taken 1617505 times.
14557545 for(int32_t q = 0; q < 8; ++q)
12797 {
12798
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 12796160 times.
12940040 if(zmeta_version < 3)
12799 {
12800
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 4748040 times.
4891920 for(int32_t c = 0; c < 33; ++c)
12801 {
12802
2/4
✓ Branch 0 taken 4748040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4748040 times.
✗ Branch 3 not taken.
4748040 if(!p_getc(&(b33[c]),f))
12803 {
12804 return qe_invalid;
12805 }
12806 4748040 }
12807
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.run_idens[q].assign(b33);
12808 143880 }
12809 else
12810 {
12811
2/4
✓ Branch 0 taken 12796160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12796160 times.
✗ Branch 3 not taken.
12796160 if(!p_getcstr(&temp_meta.run_idens[q],f))
12812 {
12813 return qe_invalid;
12814 }
12815 }
12816 12940040 }
12817
12818
2/2
✓ Branch 0 taken 1617505 times.
✓ Branch 1 taken 12940040 times.
14557545 for(int32_t q = 0; q < 8; ++q)
12819 {
12820
2/4
✓ Branch 0 taken 12940040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12940040 times.
✗ Branch 3 not taken.
12940040 if(!p_getc(&(temp_meta.run_types[q]),f))
12821 {
12822 return qe_invalid;
12823 }
12824 12940040 }
12825
12826
2/4
✓ Branch 0 taken 1617505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1617505 times.
✗ Branch 3 not taken.
1617505 if(!p_getc(&(temp_meta.flags),f))
12827 {
12828 return qe_invalid;
12829 }
12830
12831
2/4
✓ Branch 0 taken 1617505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1617505 times.
✗ Branch 3 not taken.
1617505 if(!p_igetw(&(temp_meta.compiler_v1),f))
12832 {
12833 return qe_invalid;
12834 }
12835
12836
2/4
✓ Branch 0 taken 1617505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1617505 times.
✗ Branch 3 not taken.
1617505 if(!p_igetw(&(temp_meta.compiler_v2),f))
12837 {
12838 return qe_invalid;
12839 }
12840
12841
2/4
✓ Branch 0 taken 1617505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1617505 times.
✗ Branch 3 not taken.
1617505 if(!p_igetw(&(temp_meta.compiler_v3),f))
12842 {
12843 return qe_invalid;
12844 }
12845
12846
2/4
✓ Branch 0 taken 1617505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1617505 times.
✗ Branch 3 not taken.
1617505 if(!p_igetw(&(temp_meta.compiler_v4),f))
12847 {
12848 return qe_invalid;
12849 }
12850
12851
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 1599520 times.
1617505 if(zmeta_version == 2)
12852 {
12853
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
12854 {
12855
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
12856 {
12857 return qe_invalid;
12858 }
12859 593505 }
12860
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.script_name.assign(b33);
12861
12862
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
12863 {
12864
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
12865 {
12866 return qe_invalid;
12867 }
12868 593505 }
12869
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.author.assign(b33);
12870 17985 }
12871
1/2
✓ Branch 0 taken 1599520 times.
✗ Branch 1 not taken.
1599520 else if(zmeta_version > 2)
12872 {
12873
2/4
✓ Branch 0 taken 1599520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1599520 times.
✗ Branch 3 not taken.
1599520 if(!p_getcstr(&temp_meta.script_name,f))
12874 return qe_invalid;
12875
2/4
✓ Branch 0 taken 1599520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1599520 times.
✗ Branch 3 not taken.
1599520 if(!p_getcstr(&temp_meta.author,f))
12876 return qe_invalid;
12877 1599520 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
12878
2/2
✓ Branch 0 taken 15995200 times.
✓ Branch 1 taken 1599520 times.
17594720 for(auto q = 0; q < num_meta_attrib; ++q)
12879 {
12880
2/4
✓ Branch 0 taken 15995200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15995200 times.
✗ Branch 3 not taken.
15995200 if(!p_getcstr(&temp_meta.attributes[q],f))
12881 return qe_invalid;
12882
2/4
✓ Branch 0 taken 15995200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15995200 times.
✗ Branch 3 not taken.
15995200 if(!p_getwstr(&temp_meta.attributes_help[q],f))
12883 return qe_invalid;
12884 15995200 }
12885
2/2
✓ Branch 0 taken 12796160 times.
✓ Branch 1 taken 1599520 times.
14395680 for(auto q = 0; q < 8; ++q)
12886 {
12887
2/4
✓ Branch 0 taken 12796160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12796160 times.
✗ Branch 3 not taken.
12796160 if(!p_getcstr(&temp_meta.attribytes[q],f))
12888 return qe_invalid;
12889
2/4
✓ Branch 0 taken 12796160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12796160 times.
✗ Branch 3 not taken.
12796160 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
12890 return qe_invalid;
12891 12796160 }
12892
2/2
✓ Branch 0 taken 12796160 times.
✓ Branch 1 taken 1599520 times.
14395680 for(auto q = 0; q < 8; ++q)
12893 {
12894
2/4
✓ Branch 0 taken 12796160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12796160 times.
✗ Branch 3 not taken.
12796160 if(!p_getcstr(&temp_meta.attrishorts[q],f))
12895 return qe_invalid;
12896
2/4
✓ Branch 0 taken 12796160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12796160 times.
✗ Branch 3 not taken.
12796160 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
12897 return qe_invalid;
12898 12796160 }
12899
2/2
✓ Branch 0 taken 25592320 times.
✓ Branch 1 taken 1599520 times.
27191840 for(auto q = 0; q < 16; ++q)
12900 {
12901
2/4
✓ Branch 0 taken 25592320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25592320 times.
✗ Branch 3 not taken.
25592320 if(!p_getcstr(&temp_meta.usrflags[q],f))
12902 return qe_invalid;
12903
2/4
✓ Branch 0 taken 25592320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25592320 times.
✗ Branch 3 not taken.
25592320 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
12904 return qe_invalid;
12905 25592320 }
12906 1599520 }
12907
2/2
✓ Branch 0 taken 1599520 times.
✓ Branch 1 taken 17985 times.
1617505 if(zmeta_version > 3)
12908 {
12909
2/2
✓ Branch 0 taken 12796160 times.
✓ Branch 1 taken 1599520 times.
14395680 for(auto q = 0; q < 8; ++q)
12910 {
12911
2/4
✓ Branch 0 taken 12796160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12796160 times.
✗ Branch 3 not taken.
12796160 if(!p_getcstr(&temp_meta.initd[q],f))
12912 return qe_invalid;
12913
2/4
✓ Branch 0 taken 12796160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12796160 times.
✗ Branch 3 not taken.
12796160 if(!p_getwstr(&temp_meta.initd_help[q],f))
12914 return qe_invalid;
12915 12796160 }
12916
2/2
✓ Branch 0 taken 12796160 times.
✓ Branch 1 taken 1599520 times.
14395680 for(auto q = 0; q < 8; ++q)
12917 {
12918
2/4
✓ Branch 0 taken 12796160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12796160 times.
✗ Branch 3 not taken.
12796160 if(!p_getc(&temp_meta.initd_type[q],f))
12919 return qe_invalid;
12920 12796160 }
12921 1599520 }
12922 else
12923 {
12924
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 17985 times.
161865 for(auto q = 0; q < 8; ++q)
12925 {
12926
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.initd[q] = temp_meta.run_idens[q];
12927 143880 }
12928 }
12929
12930
1/2
✓ Branch 0 taken 1617505 times.
✗ Branch 1 not taken.
1617505 (*script)->meta = temp_meta;
12931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1617505 times.
1617505 }
12932
12933
2/2
✓ Branch 0 taken 94445862 times.
✓ Branch 1 taken 140726 times.
94586588 for(int32_t j=0; j<num_commands; j++)
12934 {
12935
1/2
✓ Branch 0 taken 94445862 times.
✗ Branch 1 not taken.
94445862 auto& sc = zasm.emplace_back();
12936
2/4
✓ Branch 0 taken 94445862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94445862 times.
✗ Branch 3 not taken.
94445862 if(!p_igetw(&sc.command,f))
12937 {
12938 return qe_invalid;
12939 }
12940
12941
2/2
✓ Branch 0 taken 92677456 times.
✓ Branch 1 taken 1768406 times.
94445862 if(sc.command == 0xFFFF)
12942 {
12943 1768406 break;
12944 }
12945
12946
2/4
✓ Branch 0 taken 92677456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92677456 times.
✗ Branch 3 not taken.
92677456 if(!p_igetl(&sc.arg1,f))
12947 {
12948 return qe_invalid;
12949 }
12950
12951
2/4
✓ Branch 0 taken 92677456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92677456 times.
✗ Branch 3 not taken.
92677456 if(!p_igetl(&sc.arg2,f))
12952 {
12953 return qe_invalid;
12954 }
12955
12956
2/2
✓ Branch 0 taken 2346891 times.
✓ Branch 1 taken 90330565 times.
92677456 if(s_version >= 24)
12957
2/4
✓ Branch 0 taken 2346891 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2346891 times.
✗ Branch 3 not taken.
2346891 if(!p_igetl(&sc.arg3,f))
12958 return qe_invalid;
12959
12960
2/2
✓ Branch 0 taken 8602622 times.
✓ Branch 1 taken 84074834 times.
92677456 if(s_version >= 21)
12961 {
12962 8602622 uint32_t sz = 0;
12963
2/4
✓ Branch 0 taken 8602622 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8602622 times.
✗ Branch 3 not taken.
8602622 if(!p_igetl(&sz,f))
12964 {
12965 return qe_invalid;
12966 }
12967
2/2
✓ Branch 0 taken 33953 times.
✓ Branch 1 taken 8568669 times.
8602622 if(sz) //string found
12968 {
12969
1/2
✓ Branch 0 taken 33953 times.
✗ Branch 1 not taken.
33953 sc.strptr = new std::string();
12970 char dummy;
12971
2/2
✓ Branch 0 taken 1310233 times.
✓ Branch 1 taken 33953 times.
1344186 for(size_t q = 0; q < sz; ++q)
12972 {
12973
2/4
✓ Branch 0 taken 1310233 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1310233 times.
✗ Branch 3 not taken.
1310233 if(!p_getc(&dummy,f))
12974 {
12975 return qe_invalid;
12976 }
12977
1/2
✓ Branch 0 taken 1310233 times.
✗ Branch 1 not taken.
1310233 sc.strptr->push_back(dummy);
12978 1310233 }
12979 33953 }
12980
2/4
✓ Branch 0 taken 8602622 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8602622 times.
✗ Branch 3 not taken.
8602622 if(!p_igetl(&sz,f))
12981 {
12982 return qe_invalid;
12983 }
12984
2/2
✓ Branch 0 taken 2239 times.
✓ Branch 1 taken 8600383 times.
8602622 if(sz) //vector found
12985 {
12986
1/2
✓ Branch 0 taken 2239 times.
✗ Branch 1 not taken.
2239 sc.vecptr = new std::vector<int32_t>();
12987 int32_t dummy;
12988
2/2
✓ Branch 0 taken 14870 times.
✓ Branch 1 taken 2239 times.
17109 for(size_t q = 0; q < sz; ++q)
12989 {
12990
2/4
✓ Branch 0 taken 14870 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14870 times.
✗ Branch 3 not taken.
14870 if(!p_igetl(&dummy,f))
12991 {
12992 return qe_invalid;
12993 }
12994
1/2
✓ Branch 0 taken 14870 times.
✗ Branch 1 not taken.
14870 sc.vecptr->push_back(dummy);
12995 14870 }
12996 2239 }
12997 8602622 }
12998 92677456 }
12999
13000 // If the first command is unknown, invalidate the whole thing.
13001 // Saw this for https://www.purezc.net/index.php?page=quests&id=411 hero script 0
13002
5/6
✓ Branch 0 taken 1768406 times.
✓ Branch 1 taken 140726 times.
✓ Branch 2 taken 1755200 times.
✓ Branch 3 taken 13206 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1755200 times.
1909132 if (!zasm.empty() && zasm[0].command >= NUMCOMMANDS && zasm[0].command != 0xFFFF)
13003 {
13004 al_trace("Warning: found script with bad instruction, disabling script: %s %d\n", ScriptTypeToString((*script)->id.type), (*script)->id.index);
13005 zasm.clear();
13006 }
13007
13008 1909132 zasm_script_id id = zasm_scripts.size();
13009
3/6
✓ Branch 0 taken 1909132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1909132 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1909132 times.
✗ Branch 5 not taken.
1909132 auto& zs = zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, (*script)->name(), std::move(zasm)));
13010 1909132 (*script)->zasm_script = zs;
13011
13012 1909132 return 0;
13013 1909132 }
13014
13015 extern SAMPLE customsfxdata[WAV_COUNT];
13016 extern uint8_t customsfxflag[WAV_COUNT>>3];
13017 extern int32_t sfxdat;
13018 extern DATAFILE *sfxdata;
13019 const char *old_sfx_string[Z35] =
13020 {
13021 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13022 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13023 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13024 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13025 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13026 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13027 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13028 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13029 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13030 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13031 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13032 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13033 };
13034 char *sfx_string[WAV_COUNT];
13035
13036 610 int32_t readsfx(PACKFILE *f, zquestheader *Header)
13037 {
13038 //these are here to bypass compiler warnings about unused arguments
13039 610 Header=Header;
13040
13041 int32_t dummy;
13042 610 word s_version=0, s_cversion=0;
13043 //int32_t ret;
13044 610 SAMPLE temp_sample = {};
13045 610 temp_sample.loop_start=0;
13046 610 temp_sample.loop_end=0;
13047 610 temp_sample.param=0;
13048
13049 //section version info
13050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if(!p_igetw(&s_version,f))
13051 {
13052 return qe_invalid;
13053 }
13054
13055 610 FFCore.quest_format[vSFX] = s_version;
13056
13057
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_igetw(&s_cversion,f))
13058 {
13059 return qe_invalid;
13060 }
13061
13062 //section size
13063
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_igetl(&dummy,f))
13064 {
13065 return qe_invalid;
13066 }
13067
13068 /* HIGHLY UNORTHODOX UPDATING THING, by L
13069 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13070 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13071 * changing from 1 to 2.
13072 */
13073
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(s_version < 2)
13074 set_qr(qr_GOTOLESSNOTEQUAL,1);
13075
13076 /* End highly unorthodox updating thing */
13077
13078 610 int32_t wavcount = WAV_COUNT;
13079
13080
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(s_version < 6)
13081 wavcount = 128;
13082
13083 uint8_t tempflag[WAV_COUNT>>3];
13084
13085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if(s_version < 4)
13086 {
13087 memset(tempflag, 0xFF, WAV_COUNT>>3);
13088 }
13089 else
13090 {
13091
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(s_version < 6)
13092 memset(tempflag, 0, WAV_COUNT>>3);
13093
13094
2/2
✓ Branch 0 taken 19520 times.
✓ Branch 1 taken 610 times.
20130 for(int32_t i=0; i<(wavcount>>3); i++)
13095 {
13096 19520 p_getc(&tempflag[i], f);
13097 19520 }
13098
13099 }
13100
13101
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(s_version>4)
13102 {
13103
2/2
✓ Branch 0 taken 155550 times.
✓ Branch 1 taken 610 times.
156160 for(int32_t i=1; i<WAV_COUNT; i++)
13104 {
13105 155550 sprintf(sfx_string[i],"s%03d",i);
13106
13107
2/2
✓ Branch 0 taken 118950 times.
✓ Branch 1 taken 36600 times.
155550 if((i<Z35))
13108 36600 strcpy(sfx_string[i], old_sfx_string[i-1]);
13109
13110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155550 times.
155550 if(i>=wavcount)
13111 continue;
13112
2/2
✓ Branch 0 taken 35861 times.
✓ Branch 1 taken 119689 times.
155550 if(get_bit(tempflag, i-1))
13113 {
13114 char tempname[36];
13115
13116
1/2
✓ Branch 0 taken 35861 times.
✗ Branch 1 not taken.
35861 if(!pfread(tempname, 36, f))
13117 {
13118 return qe_invalid;
13119 }
13120
13121 35861 sfx_string[i][0] = '\0';
13122 35861 strncat(sfx_string[i], tempname, 36 - 1);
13123 35861 }
13124 else
13125 {
13126 119689 sprintf(sfx_string[i],"s%03d",i);
13127
13128
2/2
✓ Branch 0 taken 110529 times.
✓ Branch 1 taken 9160 times.
119689 if(i<Z35)
13129 9160 strcpy(sfx_string[i], old_sfx_string[i-1]);
13130 119689 sfx_string[i][35] = 0; //Force NULL Termination
13131 }
13132 155550 }
13133 610 }
13134 else
13135 {
13136 for(int32_t i=1; i<WAV_COUNT; i++)
13137 {
13138 sprintf(sfx_string[i],"s%03d",i);
13139
13140 if(i<Z35)
13141 strcpy(sfx_string[i], old_sfx_string[i-1]);
13142 }
13143 }
13144
13145 //finally... section data
13146
2/2
✓ Branch 0 taken 155550 times.
✓ Branch 1 taken 610 times.
156160 for(int32_t i=1; i<wavcount; i++)
13147 {
13148
2/2
✓ Branch 0 taken 35861 times.
✓ Branch 1 taken 119689 times.
155550 if(get_bit(tempflag, i-1))
13149 {
13150
13151
1/2
✓ Branch 0 taken 35861 times.
✗ Branch 1 not taken.
35861 if(!p_igetl(&dummy,f))
13152 {
13153 return qe_invalid;
13154 }
13155
13156 35861 (temp_sample.bits) = dummy;
13157
13158
1/2
✓ Branch 0 taken 35861 times.
✗ Branch 1 not taken.
35861 if(!p_igetl(&dummy,f))
13159 {
13160 return qe_invalid;
13161 }
13162
13163 35861 (temp_sample.stereo) = dummy;
13164
13165
1/2
✓ Branch 0 taken 35861 times.
✗ Branch 1 not taken.
35861 if(!p_igetl(&dummy,f))
13166 {
13167 return qe_invalid;
13168 }
13169
13170 35861 (temp_sample.freq) = dummy;
13171
13172
1/2
✓ Branch 0 taken 35861 times.
✗ Branch 1 not taken.
35861 if(!p_igetl(&dummy,f))
13173 {
13174 return qe_invalid;
13175 }
13176
13177 35861 (temp_sample.priority) = dummy;
13178
13179
1/2
✓ Branch 0 taken 35861 times.
✗ Branch 1 not taken.
35861 if(!p_igetl(&(temp_sample.len),f))
13180 {
13181 return qe_invalid;
13182 }
13183
13184
1/2
✓ Branch 0 taken 35861 times.
✗ Branch 1 not taken.
35861 if(!p_igetl(&(temp_sample.loop_start),f))
13185 {
13186 return qe_invalid;
13187 }
13188
13189
1/2
✓ Branch 0 taken 35861 times.
✗ Branch 1 not taken.
35861 if(!p_igetl(&(temp_sample.loop_end),f))
13190 {
13191 return qe_invalid;
13192 }
13193
13194
1/2
✓ Branch 0 taken 35861 times.
✗ Branch 1 not taken.
35861 if(!p_igetl(&(temp_sample.param),f))
13195 {
13196 return qe_invalid;
13197 }
13198
13199 35861 auto len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13200 #ifdef ZC_FUZZ
13201 const int32_t sfx_limit = 100000;
13202 if (len < 0 || len > sfx_limit)
13203 {
13204 return qe_invalid;
13205 }
13206 #endif
13207 35861 temp_sample.data = calloc(len,1);
13208
13209
1/2
✓ Branch 0 taken 35861 times.
✗ Branch 1 not taken.
35861 if(s_version < 3)
13210 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13211
13212 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35861 times.
35861 if(s_version < 2)
13214 {
13215 if(!pfread(temp_sample.data, len,f))
13216 {
13217 return qe_invalid;
13218 }
13219 }
13220 else
13221 {
13222 //re-endianfy the data
13223 35861 int32_t wordstoread = len / sizeof(word);
13224
13225
2/2
✓ Branch 0 taken 977684238 times.
✓ Branch 1 taken 35861 times.
977720099 for(int32_t j=0; j<wordstoread; j++)
13226 {
13227 word temp;
13228
13229
1/2
✓ Branch 0 taken 977684238 times.
✗ Branch 1 not taken.
977684238 if(!p_igetw(&temp, f))
13230 {
13231 return qe_invalid;
13232 }
13233
13234 977684238 ((word *)temp_sample.data)[j] = temp;
13235 977684238 }
13236 }
13237 35861 }
13238
2/2
✓ Branch 0 taken 9160 times.
✓ Branch 1 taken 110529 times.
119689 else if(i < Z35)
13239 {
13240 9160 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13241 9160 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13242 9160 set_bit(tempflag, i-1, 1);
13243 9160 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13244 9160 temp_sample.data = calloc(len,1);
13245 9160 memcpy(temp_sample.data, datsamp->data, len);
13246 9160 }
13247 110529 else continue;
13248
13249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45021 times.
45021 if(customsfxdata[i].data!=NULL)
13250 {
13251 // delete [] customsfxdata[i].data;
13252 45021 free(customsfxdata[i].data);
13253 45021 }
13254
13255 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13256 45021 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13257 45021 customsfxdata[i].data = calloc(len2,1);
13258 45021 customsfxdata[i].bits = temp_sample.bits;
13259 45021 customsfxdata[i].stereo = temp_sample.stereo;
13260 45021 customsfxdata[i].freq = temp_sample.freq;
13261 45021 customsfxdata[i].priority = temp_sample.priority;
13262 45021 customsfxdata[i].len = temp_sample.len;
13263 45021 customsfxdata[i].loop_start = temp_sample.loop_start;
13264 45021 customsfxdata[i].loop_end = temp_sample.loop_end;
13265 45021 customsfxdata[i].param = temp_sample.param;
13266 45021 int32_t cpylen = len2;
13267
13268
1/2
✓ Branch 0 taken 45021 times.
✗ Branch 1 not taken.
45021 if(s_version<3)
13269 {
13270 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13271 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13272 }
13273
13274 45021 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13275
13276 45021 free(temp_sample.data);
13277 45021 }
13278
13279 610 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13280
13281 610 sfxdat=0;
13282 610 return 0;
13283 610 }
13284
13285 692 void setupsfx()
13286 {
13287
2/2
✓ Branch 0 taken 176460 times.
✓ Branch 1 taken 692 times.
177152 for(int32_t i=1; i<WAV_COUNT; i++)
13288 {
13289 176460 sprintf(sfx_string[i],"s%03d",i);
13290
13291
2/2
✓ Branch 0 taken 134940 times.
✓ Branch 1 taken 41520 times.
176460 if(i<Z35)
13292 {
13293 41520 strcpy(sfx_string[i], old_sfx_string[i-1]);
13294 41520 }
13295
13296 176460 memset(customsfxflag, 0, WAV_COUNT>>3);
13297
13298 176460 int32_t j=i;
13299
13300
2/2
✓ Branch 0 taken 42212 times.
✓ Branch 1 taken 134248 times.
176460 if(i>Z35)
13301 {
13302 134248 i=Z35;
13303 134248 }
13304
13305 176460 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13306
13307
2/2
✓ Branch 0 taken 79560 times.
✓ Branch 1 taken 96900 times.
176460 if(customsfxdata[j].data!=NULL)
13308 {
13309 // delete [] customsfxdata[j].data;
13310 96900 free(customsfxdata[j].data);
13311 96900 }
13312
13313 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13314 176460 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13315 176460 customsfxdata[j].bits = temp_sample->bits;
13316 176460 customsfxdata[j].stereo = temp_sample->stereo;
13317 176460 customsfxdata[j].freq = temp_sample->freq;
13318 176460 customsfxdata[j].priority = temp_sample->priority;
13319 176460 customsfxdata[j].len = temp_sample->len;
13320 176460 customsfxdata[j].loop_start = temp_sample->loop_start;
13321 176460 customsfxdata[j].loop_end = temp_sample->loop_end;
13322 176460 customsfxdata[j].param = temp_sample->param;
13323 176460 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13324 176460 i=j;
13325 176460 }
13326 692 }
13327
13328 extern char *guy_string[eMAXGUYS];
13329 extern const char *old_guy_string[OLDMAXGUYS];
13330
13331 692 int32_t readguys(PACKFILE *f, zquestheader *Header)
13332 {
13333
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 669 times.
692 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_guys);
13334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
692 if (should_skip) return 0;
13335
13336 dword dummy;
13337 word guy_cversion;
13338 692 word guyversion=0;
13339
13340
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 669 times.
692 if(Header->zelda_version >= 0x193)
13341 {
13342 //section version info
13343
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&guyversion,f))
13344 {
13345 return qe_invalid;
13346 }
13347
13348 669 FFCore.quest_format[vGuys] = guyversion;
13349
13350
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&guy_cversion,f))
13351 {
13352 return qe_invalid;
13353 }
13354 669 al_trace("Guy CVersion is: %d\n", guy_cversion);
13355 //section size
13356
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetl(&dummy,f))
13357 {
13358 return qe_invalid;
13359 }
13360 669 }
13361
13362
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 82 times.
692 if(guyversion > 3)
13363 {
13364
2/2
✓ Branch 0 taken 312320 times.
✓ Branch 1 taken 610 times.
312930 for(int32_t i=0; i<MAXGUYS; i++)
13365 {
13366 char tempname[64];
13367
13368 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13369 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13370
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 312320 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
312320 if(guyversion < 23 && i >= OLDBETAMAXGUYS)
13371 {
13372 memset(tempname, 0, sizeof(char)*64);
13373 sprintf(tempname, "e%03d", i);
13374 strcpy(guy_string[i], tempname);
13375
13376 continue;
13377 }
13378
13379
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!pfread(tempname, 64, f))
13380 {
13381 return qe_invalid;
13382 }
13383
13384 // Don't retain names of uneditable enemy entries!
13385 // for version upgrade to 2.5
13386
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 312320 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
312320 if(guyversion < 23 && i >= 177)
13387 {
13388 // some of the older builds have names such as 'zz123',
13389 // (this order gets messed up with some eXXX and some zzXXX)
13390 // so let's update to the newer naming convection. -Gleeok
13391 char tmpbuf[64];
13392 memset(tmpbuf, 0, sizeof(char)*64);
13393 sprintf(tmpbuf, "zz%03d", i);
13394
13395 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13396 {
13397 memset(tempname, 0, sizeof(char)*64);
13398 sprintf(tempname, "e%03d", i);
13399 }
13400 }
13401
13402
6/6
✓ Branch 0 taken 107970 times.
✓ Branch 1 taken 204350 times.
✓ Branch 2 taken 102480 times.
✓ Branch 3 taken 5490 times.
✓ Branch 4 taken 93257 times.
✓ Branch 5 taken 9223 times.
312320 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13403 {
13404 303097 guy_string[i][0] = '\0';
13405 303097 strncat(guy_string[i], tempname, 64 - 1);
13406 303097 }
13407 else
13408 {
13409 9223 strcpy(guy_string[i],old_guy_string[i]);
13410 }
13411 312320 }
13412 610 }
13413 else
13414 {
13415
2/2
✓ Branch 0 taken 41984 times.
✓ Branch 1 taken 82 times.
42066 for(int32_t i=0; i<eMAXGUYS; i++)
13416 {
13417 41984 sprintf(guy_string[i],"zz%03d",i);
13418 41984 }
13419
13420
2/2
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 82 times.
14596 for(int32_t i=0; i<OLDMAXGUYS; i++)
13421 {
13422 14514 strcpy(guy_string[i],old_guy_string[i]);
13423 14514 }
13424 }
13425
13426
13427 //finally... section data
13428 692 init_guys(guyversion); //using default data for now...
13429
13430 // Goriya guy fix
13431
3/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 610 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
692 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13432 {
13433
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 60 times.
82 if(get_qr(qr_NEWENEMYTILES))
13434 {
13435 60 guysbuf[gGORIYA].tile=130;
13436 60 guysbuf[gGORIYA].e_tile=130;
13437 60 }
13438 82 }
13439
13440
2/2
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 23 times.
692 if(Header->zelda_version < 0x193)
13441 {
13442
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 5 times.
23 if(get_bit(deprecated_rules,46))
13443 {
13444 5 guysbuf[eDODONGO].cset=14;
13445 5 guysbuf[eDODONGO].bosspal=spDIG;
13446 5 }
13447 23 }
13448 // Not sure when this first changed, but it's necessary for 2.10, at least
13449 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13450 //2.10 Fixes
13451
3/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 610 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
692 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13452 {
13453 82 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13454 82 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13455 82 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13456 82 guysbuf[eCENT1].attributes[2] = 1;
13457 82 guysbuf[eCENT2].attributes[2] = 1;
13458 82 }
13459
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
692 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13460 {
13461 692 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13462 692 }
13463
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 82 times.
692 if(Header->zelda_version <= 0x210)
13464 {
13465 82 guysbuf[eGLEEOK1F].attributes[5] = 16;
13466 82 guysbuf[eGLEEOK2F].attributes[5] = 16;
13467 82 guysbuf[eGLEEOK3F].attributes[5] = 16;
13468 82 guysbuf[eGLEEOK4F].attributes[5] = 16;
13469
13470 82 guysbuf[eWIZ1].attributes[3] = 1; //only set the enemy that needs backward compat, not all of them.
13471 82 guysbuf[eBATROBE].attributes[3] = 1;
13472 //guysbuf[eSUMMONER].misc4 = 1;
13473 82 guysbuf[eWWIZ].attributes[3] = 1;
13474 82 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13475 82 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13476 82 }
13477
2/2
✓ Branch 0 taken 680 times.
✓ Branch 1 taken 12 times.
692 if(Header->zelda_version == 0x190)
13478 {
13479 12 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13480 12 guysbuf[eKEESETRIB].attributes[2] = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13481 12 guysbuf[eGELTRIB].attributes[2] = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13482 12 }
13483
13484 // The versions here may not be correct
13485 // zelda_version>=0x211 handled at guyversion<24
13486
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 674 times.
692 if(Header->zelda_version <= 0x190)
13487 {
13488 18 guysbuf[eCENT1].attributes[2] = 0;
13489 18 guysbuf[eCENT2].attributes[2] = 0;
13490 18 guysbuf[eMOLDORM].attributes[1] = 0;
13491 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13492 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13493 18 }
13494
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 64 times.
674 else if(Header->zelda_version <= 0x210)
13495 {
13496 64 guysbuf[eCENT1].attributes[2] = 1;
13497 64 guysbuf[eCENT2].attributes[2] = 1;
13498 64 guysbuf[eMOLDORM].attributes[1] = 0;
13499 64 }
13500
13501
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 82 times.
692 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13502 {
13503 82 guysbuf[eKEESE1].attributes[15] = 120;
13504 82 guysbuf[eKEESE2].attributes[15] = 120;
13505 82 guysbuf[eKEESE3].attributes[15] = 120;
13506 82 guysbuf[eKEESETRIB].attributes[15] = 120;
13507 82 guysbuf[eKEESE1].attributes[16] = 16;
13508 82 guysbuf[eKEESE2].attributes[16] = 16;
13509 82 guysbuf[eKEESE3].attributes[16] = 16;
13510 82 guysbuf[eKEESETRIB].attributes[16] = 16;
13511
13512 82 guysbuf[ePEAHAT].attributes[15] = 80;
13513 82 guysbuf[ePEAHAT].attributes[16] = 16;
13514
13515 82 guysbuf[eGHINI2].attributes[15] = 120;
13516 82 guysbuf[eGHINI2].attributes[16] = 10;
13517
13518
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 66 times.
82 if (replay_version_check(20))
13519 {
13520 66 guysbuf[eGHINI2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13521 66 guysbuf[eMOLDORM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13522 66 guysbuf[eKEESETRIB].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13523 66 guysbuf[eKEESE3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13524 66 guysbuf[eKEESE2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13525 66 guysbuf[eKEESE1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13526 66 guysbuf[eTEK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13527 66 guysbuf[eTEK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13528 66 guysbuf[ePEAHAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13529 66 guysbuf[eROCK].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13530 66 guysbuf[eTRAP].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13531 66 guysbuf[eWALLM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13532 66 guysbuf[ePOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13533 66 guysbuf[eMANHAN].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13534 66 guysbuf[eGLEEOK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13535 66 guysbuf[eGLEEOK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13536 66 guysbuf[eGLEEOK3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13537 66 guysbuf[eGLEEOK4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13538 66 guysbuf[eDIG1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13539 66 guysbuf[eDIG3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13540 66 guysbuf[eDIGPUP1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13541 66 guysbuf[eDIGPUP2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13542 66 guysbuf[eDIGPUP3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13543 66 guysbuf[eDIGPUP4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13544 66 guysbuf[eRAQUAM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13545 66 guysbuf[eITEMFAIRY].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13546 66 guysbuf[eFIRE].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13547 66 guysbuf[eMANHAN2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13548 66 guysbuf[eTRAP_H].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13549 66 guysbuf[eTRAP_V].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13550 66 guysbuf[eTRAP_LR].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13551 66 guysbuf[eTRAP_UD].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13552 66 guysbuf[ePATRA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13553 66 guysbuf[ePATRA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13554 66 guysbuf[ePATRABS].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13555 66 guysbuf[eBAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13556 66 guysbuf[eGLEEOK1F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13557 66 guysbuf[eGLEEOK2F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13558 66 guysbuf[eGLEEOK3F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13559 66 guysbuf[eGLEEOK4F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13560 66 guysbuf[eTRIGGER].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13561 66 guysbuf[ePATRAL2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13562 66 guysbuf[ePATRAL3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13563 66 guysbuf[eGOHMA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13564 66 guysbuf[eGOHMA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13565 66 guysbuf[eGOHMA3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13566 66 guysbuf[eGOHMA4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13567 66 guysbuf[eMPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13568 66 guysbuf[eWPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13569 66 }
13570 82 }
13571
13572
13573
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 610 times.
692 if(guyversion<=2)
13574 {
13575 82 return readherosprites2(f, guyversion==2?0:-1, 0);
13576 }
13577
13578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if(guyversion > 3)
13579 {
13580 guydata tempguy;
13581
13582
2/2
✓ Branch 0 taken 312320 times.
✓ Branch 1 taken 610 times.
312930 for(int32_t i=0; i<MAXGUYS; i++)
13583 {
13584
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(guyversion < 23) // May 2012 : 512 max enemies
13585 {
13586 if(i >= OLDBETAMAXGUYS)
13587 {
13588 memset(&guysbuf[i], 0, sizeof(guydata));
13589 continue;
13590 }
13591 }
13592
13593 312320 memset(&tempguy, 0, sizeof(guydata));
13594
13595
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_igetl(&(tempguy.flags),f))
13596 {
13597 return qe_invalid;
13598 }
13599
13600
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_igetl(&(tempguy.flags2),f))
13601 {
13602 return qe_invalid;
13603 }
13604
13605
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 96768 times.
312320 if ( guyversion >= 36 ) //expanded tiles
13606 {
13607
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_igetl(&(tempguy.tile),f))
13608 {
13609 return qe_invalid;
13610 }
13611 215552 }
13612 else
13613 {
13614
1/2
✓ Branch 0 taken 96768 times.
✗ Branch 1 not taken.
96768 if(!p_igetw(&(tempguy.tile),f))
13615 {
13616 return qe_invalid;
13617 }
13618 }
13619
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_getc(&(tempguy.width),f))
13620 {
13621 return qe_invalid;
13622 }
13623
13624
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_getc(&(tempguy.height),f))
13625 {
13626 return qe_invalid;
13627 }
13628
13629
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 96768 times.
312320 if ( guyversion >= 36 ) //expanded tiles
13630 {
13631
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_igetl(&(tempguy.s_tile),f))
13632 {
13633 return qe_invalid;
13634 }
13635 215552 }
13636 else
13637 {
13638
1/2
✓ Branch 0 taken 96768 times.
✗ Branch 1 not taken.
96768 if(!p_igetw(&(tempguy.s_tile),f))
13639 {
13640 return qe_invalid;
13641 }
13642 }
13643
13644
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_getc(&(tempguy.s_width),f))
13645 {
13646 return qe_invalid;
13647 }
13648
13649
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_getc(&(tempguy.s_height),f))
13650 {
13651 return qe_invalid;
13652 }
13653
13654
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 96768 times.
312320 if ( guyversion >= 36 ) //expanded tiles
13655 {
13656
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_igetl(&(tempguy.e_tile),f))
13657 {
13658 return qe_invalid;
13659 }
13660 215552 }
13661 else
13662 {
13663
1/2
✓ Branch 0 taken 96768 times.
✗ Branch 1 not taken.
96768 if(!p_igetw(&(tempguy.e_tile),f))
13664 {
13665 return qe_invalid;
13666 }
13667 }
13668
13669
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_getc(&(tempguy.e_width),f))
13670 {
13671 return qe_invalid;
13672 }
13673
13674
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_getc(&(tempguy.e_height),f))
13675 {
13676 return qe_invalid;
13677 }
13678
13679
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_igetw(&(tempguy.hp),f))
13680 {
13681 return qe_invalid;
13682 }
13683
13684
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_igetw(&(tempguy.family),f))
13685 {
13686 return qe_invalid;
13687 }
13688
13689
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 312320 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
312320 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
13690 {
13691 if(get_qr(qr_NEWENEMYTILES))
13692 {
13693 tempguy.s_tile=tempguy.e_tile+120;
13694 tempguy.s_width=tempguy.e_width;
13695 tempguy.s_height=tempguy.e_height;
13696 }
13697 else tempguy.s_tile=860;
13698 }
13699
13700
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_igetw(&(tempguy.cset),f))
13701 {
13702 return qe_invalid;
13703 }
13704
13705
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_igetw(&(tempguy.anim),f))
13706 {
13707 return qe_invalid;
13708 }
13709
13710
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_igetw(&(tempguy.e_anim),f))
13711 {
13712 return qe_invalid;
13713 }
13714
13715
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_igetw(&(tempguy.frate),f))
13716 {
13717 return qe_invalid;
13718 }
13719
13720
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_igetw(&(tempguy.e_frate),f))
13721 {
13722 return qe_invalid;
13723 }
13724
13725
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(guyversion < 13) // April 2009
13726 {
13727 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
13728 {
13729 tempguy.frate *= 2;
13730 tempguy.e_frate *= 2;
13731 }
13732 }
13733
13734
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(guyversion < 14) // May 1 2009
13735 {
13736 if(tempguy.anim==a2FRMSLOW)
13737 {
13738 tempguy.anim=a2FRM;
13739 tempguy.frate *= 2;
13740 }
13741
13742 if(tempguy.e_anim==a2FRMSLOW)
13743 {
13744 tempguy.e_anim=a2FRM;
13745 tempguy.e_frate *= 2;
13746 }
13747
13748 if(tempguy.anim==aFLIPSLOW)
13749 {
13750 tempguy.anim=aFLIP;
13751 tempguy.frate *= 2;
13752 }
13753
13754 if(tempguy.e_anim==aFLIPSLOW)
13755 {
13756 tempguy.e_anim=aFLIP;
13757 tempguy.e_frate *= 2;
13758 }
13759
13760 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
13761
13762 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
13763
13764 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
13765 {
13766 tempguy.anim=a4FRM4DIR;
13767 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
13768 }
13769
13770 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
13771 {
13772 tempguy.e_anim=a4FRM4DIR;
13773 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
13774 }
13775 }
13776
13777
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_igetw(&(tempguy.dp),f))
13778 {
13779 return qe_invalid;
13780 }
13781
13782 //correction for guy fire
13783
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(guyversion < 6)
13784 {
13785 if(i == gFIRE)
13786 tempguy.dp = 2;
13787 }
13788
13789
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_igetw(&(tempguy.wdp),f))
13790 {
13791 return qe_invalid;
13792 }
13793
13794
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_igetw(&(tempguy.weapon),f))
13795 {
13796 return qe_invalid;
13797 }
13798
13799 //correction for bosses using triple, "rising" fireballs
13800
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(guyversion < 5)
13801 {
13802 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
13803 i == eGOHMA3 || i == eGOHMA4)
13804 {
13805 if(tempguy.weapon == ewFireball)
13806 tempguy.weapon = ewFireball2;
13807 }
13808 }
13809
13810
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_igetw(&(tempguy.rate),f))
13811 {
13812 return qe_invalid;
13813 }
13814
13815
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_igetw(&(tempguy.hrate),f))
13816 {
13817 return qe_invalid;
13818 }
13819
13820
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_igetw(&(tempguy.step),f))
13821 {
13822 return qe_invalid;
13823 }
13824
13825 // HIGHLY UNORTHODOX UPDATING THING, part 2
13826
3/4
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 309760 times.
✓ Branch 2 taken 2560 times.
✗ Branch 3 not taken.
312320 if(fixpolsvoice && tempguy.family==eePOLSV)
13827 {
13828 tempguy.step /= 2;
13829 }
13830
13831
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_igetw(&(tempguy.homing),f))
13832 {
13833 return qe_invalid;
13834 }
13835
13836
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_igetw(&(tempguy.grumble),f))
13837 {
13838 return qe_invalid;
13839 }
13840
13841
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_igetw(&(tempguy.item_set),f))
13842 {
13843 return qe_invalid;
13844 }
13845
13846
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
13847 {
13848
2/2
✓ Branch 0 taken 3123200 times.
✓ Branch 1 taken 312320 times.
3435520 for (int q = 0; q < 10; ++q)
13849 {
13850
1/2
✓ Branch 0 taken 3123200 times.
✗ Branch 1 not taken.
3123200 if (!p_igetl(&(tempguy.attributes[q]), f))
13851 {
13852 return qe_invalid;
13853 }
13854 3123200 }
13855 312320 }
13856 else
13857 {
13858 int16_t tempMisc;
13859
13860 for(int q=0;q<10;q++)
13861 {
13862 if (!p_igetw(&tempMisc, f))
13863 {
13864 return qe_invalid;
13865 }
13866 tempguy.attributes[q] = tempMisc;
13867 }
13868
13869 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
13870 {
13871 if(tempguy.family == eeWIZZ && !(tempguy.attributes[0]))
13872 tempguy.attributes[4] = 74;
13873 }
13874
13875 }
13876
13877
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_igetw(&(tempguy.bgsfx),f))
13878 {
13879 return qe_invalid;
13880 }
13881
13882
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_igetw(&(tempguy.bosspal),f))
13883 {
13884 return qe_invalid;
13885 }
13886
13887
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_igetw(&(tempguy.extend),f))
13888 {
13889 return qe_invalid;
13890 }
13891
13892 //! Enemy Defences
13893
13894 //If a 2.50 quest, use only the 2.5 defences.
13895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 312320 times.
312320 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
13896 {
13897
2/2
✓ Branch 0 taken 5934080 times.
✓ Branch 1 taken 312320 times.
6246400 for(int32_t j=0; j<edefLAST; j++)
13898 {
13899
1/2
✓ Branch 0 taken 5934080 times.
✗ Branch 1 not taken.
5934080 if(!p_getc(&(tempguy.defense[j]),f))
13900 {
13901 return qe_invalid;
13902 }
13903 5934080 }
13904 //then copy the generic script defence to all the new script defences
13905
13906 312320 }
13907
13908
13909
13910
13911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 312320 times.
312320 if(guyversion >= 18)
13912 {
13913
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_getc(&(tempguy.hitsfx),f))
13914 {
13915 return qe_invalid;
13916 }
13917
13918
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_getc(&(tempguy.deadsfx),f))
13919 {
13920 return qe_invalid;
13921 }
13922 312320 }
13923
13924
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(guyversion >= 22)
13925 {
13926
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_igetl(&(tempguy.attributes[10]), f))
13927 {
13928 return qe_invalid;
13929 }
13930
13931
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(!p_igetl(&(tempguy.attributes[11]),f))
13932 {
13933 return qe_invalid;
13934 }
13935 312320 }
13936 else if(guyversion >= 19)
13937 {
13938 int16_t tempMisc;
13939
13940 if(!p_igetw(&tempMisc,f))
13941 {
13942 return qe_invalid;
13943 }
13944
13945 tempguy.attributes[10] = tempMisc;
13946
13947 if(!p_igetw(&tempMisc,f))
13948 {
13949 return qe_invalid;
13950 }
13951
13952 tempguy.attributes[11] = tempMisc;
13953 }
13954
13955 //If a 2.54 or later quest, use all of the defences.
13956
2/2
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 215552 times.
312320 if(guyversion > 24) // Add new guyversion conditional statement
13957 {
13958
2/2
✓ Branch 0 taken 4742144 times.
✓ Branch 1 taken 215552 times.
4957696 for(int32_t j=edefLAST; j<edefLAST255; j++)
13959 {
13960
1/2
✓ Branch 0 taken 4742144 times.
✗ Branch 1 not taken.
4742144 if(!p_getc(&(tempguy.defense[j]),f))
13961 {
13962 return qe_invalid;
13963 }
13964 4742144 }
13965 215552 }
13966
13967
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 96768 times.
312320 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
13968 {
13969
2/2
✓ Branch 0 taken 967680 times.
✓ Branch 1 taken 96768 times.
1064448 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
13970 {
13971 967680 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
13972 967680 }
13973 96768 }
13974
13975 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
13976
2/2
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 215552 times.
312320 if(guyversion > 25)
13977 {
13978
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_igetl(&(tempguy.txsz),f))
13979 {
13980 return qe_invalid;
13981 }
13982
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_igetl(&(tempguy.tysz),f))
13983 {
13984 return qe_invalid;
13985 }
13986
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_igetl(&(tempguy.hxsz),f))
13987 {
13988 return qe_invalid;
13989 }
13990
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_igetl(&(tempguy.hysz),f))
13991 {
13992 return qe_invalid;
13993 }
13994
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_igetl(&(tempguy.hzsz),f))
13995 {
13996 return qe_invalid;
13997 }
13998 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
13999
14000 */
14001 215552 }
14002 //More Enemy Editor vars for 2.60
14003
2/2
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 215552 times.
312320 if(guyversion > 26)
14004 {
14005
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_igetl(&(tempguy.hxofs),f))
14006 {
14007 return qe_invalid;
14008 }
14009
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_igetl(&(tempguy.hyofs),f))
14010 {
14011 return qe_invalid;
14012 }
14013
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_igetl(&(tempguy.xofs),f))
14014 {
14015 return qe_invalid;
14016 }
14017
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_igetl(&(tempguy.yofs),f))
14018 {
14019 return qe_invalid;
14020 }
14021
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_igetl(&(tempguy.zofs),f))
14022 {
14023 return qe_invalid;
14024 }
14025 215552 }
14026
14027
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 96768 times.
312320 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14028 {
14029 96768 tempguy.wpnsprite = 0;
14030 96768 }
14031
14032
2/2
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 215552 times.
312320 if(guyversion > 27)
14033 {
14034
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_igetl(&(tempguy.wpnsprite),f))
14035 {
14036 return qe_invalid;
14037 }
14038 215552 }
14039
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 96768 times.
312320 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14040 {
14041 96768 tempguy.SIZEflags = 0;
14042 96768 }
14043
2/2
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 215552 times.
312320 if(guyversion > 28)
14044 {
14045
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_igetl(&(tempguy.SIZEflags),f))
14046 {
14047 return qe_invalid;
14048 }
14049
14050 215552 }
14051
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 96768 times.
312320 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14052 {
14053 96768 tempguy.frozentile = 0;
14054 96768 tempguy.frozencset = 0;
14055 96768 tempguy.frozenclock = 0;
14056
2/2
✓ Branch 0 taken 967680 times.
✓ Branch 1 taken 96768 times.
1064448 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14057 96768 }
14058
2/2
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 215552 times.
312320 if(guyversion >= 30)
14059 {
14060
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_igetl(&(tempguy.frozentile),f))
14061 {
14062 return qe_invalid;
14063 }
14064
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_igetl(&(tempguy.frozencset),f))
14065 {
14066 return qe_invalid;
14067 }
14068
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_igetl(&(tempguy.frozenclock),f))
14069 {
14070 return qe_invalid;
14071 }
14072
2/2
✓ Branch 0 taken 2155520 times.
✓ Branch 1 taken 215552 times.
2371072 for ( int32_t q = 0; q < 10; q++ ) {
14073
1/2
✓ Branch 0 taken 2155520 times.
✗ Branch 1 not taken.
2155520 if(!p_igetw(&(tempguy.frozenmisc[q]),f))
14074 {
14075 return qe_invalid;
14076 }
14077 2155520 }
14078
14079 215552 }
14080
14081
2/2
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 215552 times.
312320 if(guyversion >= 34)
14082 {
14083
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_igetw(&(tempguy.firesfx),f))
14084 {
14085 return qe_invalid;
14086 }
14087
2/2
✓ Branch 0 taken 3664384 times.
✓ Branch 1 taken 215552 times.
3879936 for(int q=15;q<32;++q)
14088 {
14089
1/2
✓ Branch 0 taken 3664384 times.
✗ Branch 1 not taken.
3664384 if(!p_igetl(&(tempguy.attributes[q]),f))
14090 {
14091 return qe_invalid;
14092 }
14093 3664384 }
14094
14095
2/2
✓ Branch 0 taken 6897664 times.
✓ Branch 1 taken 215552 times.
7113216 for ( int32_t q = 0; q < 32; q++ ) {
14096
1/2
✓ Branch 0 taken 6897664 times.
✗ Branch 1 not taken.
6897664 if(!p_igetl(&(tempguy.movement[q]),f))
14097 {
14098 return qe_invalid;
14099 }
14100 6897664 }
14101
2/2
✓ Branch 0 taken 6897664 times.
✓ Branch 1 taken 215552 times.
7113216 for ( int32_t q = 0; q < 32; q++ ) {
14102
1/2
✓ Branch 0 taken 6897664 times.
✗ Branch 1 not taken.
6897664 if(!p_igetl(&(tempguy.new_weapon[q]),f))
14103 {
14104 return qe_invalid;
14105 }
14106 6897664 }
14107
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_igetw(&(tempguy.script),f))
14108 {
14109 return qe_invalid;
14110 }
14111
2/2
✓ Branch 0 taken 1724416 times.
✓ Branch 1 taken 215552 times.
1939968 for ( int32_t q = 0; q < 8; q++ )
14112 {
14113
1/2
✓ Branch 0 taken 1724416 times.
✗ Branch 1 not taken.
1724416 if(!p_igetl(&(tempguy.initD[q]),f))
14114 {
14115 return qe_invalid;
14116 }
14117 1724416 }
14118
2/2
✓ Branch 0 taken 431104 times.
✓ Branch 1 taken 215552 times.
646656 for ( int32_t q = 0; q < 2; q++ )
14119 {
14120
1/2
✓ Branch 0 taken 431104 times.
✗ Branch 1 not taken.
431104 if(!p_igetl(&(tempguy.initA[q]),f))
14121 {
14122 return qe_invalid;
14123 }
14124 431104 }
14125
14126 215552 }
14127
14128
2/2
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 215552 times.
312320 if(guyversion >= 37)
14129 {
14130
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_igetl(&(tempguy.editorflags),f))
14131 {
14132 return qe_invalid;
14133 }
14134 215552 }
14135
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 96768 times.
312320 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14136
2/2
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 215552 times.
312320 if(guyversion >= 38)
14137 {
14138
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_igetl(&(tempguy.attributes[12]),f))
14139 {
14140 return qe_invalid;
14141 }
14142
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_igetl(&(tempguy.attributes[13]),f))
14143 {
14144 return qe_invalid;
14145 }
14146
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_igetl(&(tempguy.attributes[14]),f))
14147 {
14148 return qe_invalid;
14149 }
14150
14151 215552 }
14152
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 96768 times.
312320 if ( guyversion < 38 )
14153 {
14154 96768 tempguy.attributes[12] = 0;
14155 96768 tempguy.attributes[13] = 0;
14156 96768 tempguy.attributes[14] = 0;
14157 96768 }
14158
14159
2/2
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 215552 times.
312320 if ( guyversion >= 39 )
14160 {
14161
2/2
✓ Branch 0 taken 1724416 times.
✓ Branch 1 taken 215552 times.
1939968 for ( int32_t q = 0; q < 8; q++ )
14162 {
14163
2/2
✓ Branch 0 taken 112087040 times.
✓ Branch 1 taken 1724416 times.
113811456 for ( int32_t w = 0; w < 65; w++ )
14164 {
14165
1/2
✓ Branch 0 taken 112087040 times.
✗ Branch 1 not taken.
112087040 if(!p_getc(&(tempguy.initD_label[q][w]),f))
14166 {
14167 return qe_invalid;
14168 }
14169 112087040 }
14170
2/2
✓ Branch 0 taken 112087040 times.
✓ Branch 1 taken 1724416 times.
113811456 for ( int32_t w = 0; w < 65; w++ )
14171 {
14172
1/2
✓ Branch 0 taken 112087040 times.
✗ Branch 1 not taken.
112087040 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f))
14173 {
14174 return qe_invalid;
14175 }
14176 112087040 }
14177 1724416 }
14178
14179
14180 215552 }
14181
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 96768 times.
312320 if ( guyversion < 39 ) //apply old InitD strings to both
14182 {
14183
2/2
✓ Branch 0 taken 774144 times.
✓ Branch 1 taken 96768 times.
870912 for ( int32_t q = 0; q < 8; q++ )
14184 {
14185 774144 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14186 774144 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14187 774144 }
14188 96768 }
14189
2/2
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 215552 times.
312320 if ( guyversion >= 40 )
14190 {
14191
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_igetw(&(tempguy.weaponscript),f))
14192 {
14193 return qe_invalid;
14194 }
14195 215552 }
14196
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 96768 times.
312320 if ( guyversion < 40 )
14197 {
14198 96768 tempguy.weaponscript = 0;
14199 96768 }
14200 //eweapon script InitD
14201
2/2
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 215552 times.
312320 if ( guyversion >= 41 )
14202 {
14203
2/2
✓ Branch 0 taken 1724416 times.
✓ Branch 1 taken 215552 times.
1939968 for ( int32_t q = 0; q < 8; q++ )
14204 {
14205
1/2
✓ Branch 0 taken 1724416 times.
✗ Branch 1 not taken.
1724416 if(!p_igetl(&(tempguy.weap_initiald[q]),f))
14206 {
14207 return qe_invalid;
14208 }
14209 1724416 }
14210
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if ( guy_cversion < 4 )
14211 {
14212 if ( tempguy.family == eeKEESE )
14213 {
14214
14215 if ( !tempguy.attributes[0] )
14216 {
14217 tempguy.attributes[15] = 120;
14218 tempguy.attributes[16] = 16;
14219
14220 }
14221 }
14222 if ( tempguy.family == eePEAHAT )
14223 {
14224 tempguy.attributes[15] = 80;
14225 tempguy.attributes[16] = 16;
14226 }
14227
14228 if ( tempguy.family == eeGHINI )
14229 {
14230 tempguy.attributes[15] = 120;
14231 tempguy.attributes[16] = 10;
14232 }
14233
14234 }
14235 215552 }
14236
14237
14238
14239 //default weapon sprites (quest version < 2.54)
14240 //port over old defaults -Z
14241
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 96768 times.
312320 if(guyversion < 32)
14242 {
14243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96768 times.
96768 if ( tempguy.wpnsprite <= 0 )
14244 {
14245
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2720 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 81949 times.
✓ Branch 4 taken 762 times.
✓ Branch 5 taken 659 times.
✓ Branch 6 taken 1824 times.
✓ Branch 7 taken 1227 times.
✓ Branch 8 taken 2290 times.
✓ Branch 9 taken 195 times.
✓ Branch 10 taken 77 times.
✓ Branch 11 taken 423 times.
✓ Branch 12 taken 77 times.
✓ Branch 13 taken 865 times.
✓ Branch 14 taken 1715 times.
✓ Branch 15 taken 219 times.
✓ Branch 16 taken 311 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1455 times.
96768 switch(tempguy.weapon)
14246 {
14247 case wNone:
14248 81949 tempguy.wpnsprite = 0; break;
14249
14250 case wSword:
14251 case wBeam:
14252 case wBrang:
14253 case wBomb:
14254 case wSBomb:
14255 case wLitBomb:
14256 case wLitSBomb:
14257 case wArrow:
14258 case wFire:
14259 case wWhistle:
14260 case wBait:
14261 case wWand:
14262 case wMagic:
14263 case wCatching:
14264 case wWind:
14265 case wRefMagic:
14266 case wRefFireball:
14267 case wRefRock:
14268 case wHammer:
14269 case wHookshot:
14270 case wHSHandle:
14271 case wHSChain:
14272 case wSSparkle:
14273 case wFSparkle:
14274 case wSmack:
14275 case wPhantom:
14276 case wCByrna:
14277 case wRefBeam:
14278 case wStomp:
14279 case lwMax:
14280 case wScript1:
14281 case wScript2:
14282 case wScript3:
14283 case wScript4:
14284 case wScript5:
14285 case wScript6:
14286 case wScript7:
14287 case wScript8:
14288 case wScript9:
14289 case wScript10:
14290 case wIce:
14291 //Cannot use any of these weapons yet.
14292 tempguy.wpnsprite = -1;
14293 break;
14294
14295 case wEnemyWeapons:
14296 2720 case ewFireball: tempguy.wpnsprite = 17; break;
14297
14298 762 case ewArrow: tempguy.wpnsprite = 19; break;
14299 659 case ewBrang: tempguy.wpnsprite = 4; break;
14300 1824 case ewSword: tempguy.wpnsprite = 20; break;
14301 1227 case ewRock: tempguy.wpnsprite = 18; break;
14302 2290 case ewMagic: tempguy.wpnsprite = 21; break;
14303 195 case ewBomb: tempguy.wpnsprite = 78; break;
14304 77 case ewSBomb: tempguy.wpnsprite = 79; break;
14305 423 case ewLitBomb: tempguy.wpnsprite = 76; break;
14306 77 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14307 865 case ewFireTrail: tempguy.wpnsprite = 80; break;
14308 1715 case ewFlame: tempguy.wpnsprite = 35; break;
14309 219 case ewWind: tempguy.wpnsprite = 36; break;
14310 311 case ewFlame2: tempguy.wpnsprite = 81; break;
14311 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14312 case ewIce: tempguy.wpnsprite = 83; break;
14313 1455 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14314
14315
14316 default: break; //No assign.
14317 }
14318 96768 }
14319 96768 }
14320
14321 //default weapon fire sound (quest version < 2.54)
14322 //port over old defaults and zero new data. -Z
14323
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 96768 times.
312320 if(guyversion < 34)
14324 {
14325
2/2
✓ Branch 0 taken 3096576 times.
✓ Branch 1 taken 96768 times.
3193344 for ( int32_t q = 0; q < 32; q++ )
14326 {
14327 3096576 tempguy.movement[q] = 0;
14328 3096576 tempguy.new_weapon[q] = 0;
14329
14330 3096576 }
14331
14332 //NPC Script attributes.
14333 96768 tempguy.script = 0; //No scripted enemies existed. -Z
14334
2/2
✓ Branch 0 taken 774144 times.
✓ Branch 1 taken 96768 times.
870912 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14335
2/2
✓ Branch 0 taken 193536 times.
✓ Branch 1 taken 96768 times.
290304 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14336
14337
2/2
✓ Branch 0 taken 1645056 times.
✓ Branch 1 taken 96768 times.
1741824 for ( int32_t q = 15; q < 32; q++) tempguy.attributes[q] = 0; //misc 16-32
14338
14339 //old default sounds
14340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96768 times.
96768 if ( tempguy.firesfx <= 0 )
14341 {
14342
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2720 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 81949 times.
✓ Branch 4 taken 762 times.
✓ Branch 5 taken 659 times.
✓ Branch 6 taken 1824 times.
✓ Branch 7 taken 1227 times.
✓ Branch 8 taken 2290 times.
✓ Branch 9 taken 195 times.
✓ Branch 10 taken 77 times.
✓ Branch 11 taken 423 times.
✓ Branch 12 taken 77 times.
✓ Branch 13 taken 865 times.
✓ Branch 14 taken 1715 times.
✓ Branch 15 taken 219 times.
✓ Branch 16 taken 311 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1455 times.
96768 switch(tempguy.weapon)
14343 {
14344 case wNone:
14345 81949 tempguy.firesfx = 0; break;
14346
14347 case wSword:
14348 case wBeam:
14349 case wBrang:
14350 case wBomb:
14351 case wSBomb:
14352 case wLitBomb:
14353 case wLitSBomb:
14354 case wArrow:
14355 case wFire:
14356 case wWhistle:
14357 case wBait:
14358 case wWand:
14359 case wMagic:
14360 case wCatching:
14361 case wWind:
14362 case wRefMagic:
14363 case wRefFireball:
14364 case wRefRock:
14365 case wHammer:
14366 case wHookshot:
14367 case wHSHandle:
14368 case wHSChain:
14369 case wSSparkle:
14370 case wFSparkle:
14371 case wSmack:
14372 case wPhantom:
14373 case wCByrna:
14374 case wRefBeam:
14375 case wStomp:
14376 case lwMax:
14377 case wScript1:
14378 case wScript2:
14379 case wScript3:
14380 case wScript4:
14381 case wScript5:
14382 case wScript6:
14383 case wScript7:
14384 case wScript8:
14385 case wScript9:
14386 case wScript10:
14387 case wIce:
14388 //Cannot use any of these weapons yet.
14389 tempguy.firesfx = -1;
14390 break;
14391
14392 case wEnemyWeapons:
14393 2720 case ewFireball: tempguy.firesfx = 40; break;
14394
14395 762 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14396 659 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14397 1824 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14398 1227 case ewRock: tempguy.firesfx = 51; break;
14399 2290 case ewMagic: tempguy.firesfx = 32; break;
14400 195 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14401 77 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14402 423 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14403 77 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14404 865 case ewFireTrail: tempguy.firesfx = 13; break;
14405 1715 case ewFlame: tempguy.firesfx = 13; break;
14406 219 case ewWind: tempguy.firesfx = 32; break;
14407 311 case ewFlame2: tempguy.firesfx = 13; break;
14408 case ewFlame2Trail: tempguy.firesfx = 13; break;
14409 case ewIce: tempguy.firesfx = 44; break;
14410 1455 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14411
14412 //what about special attacks (e.g. summoning == 56)
14413 default: break; //No assign.
14414 }
14415 96768 }
14416 96768 }
14417
14418 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14419
4/6
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 96768 times.
✓ Branch 2 taken 215552 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 215552 times.
312320 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14420 {
14421
2/2
✓ Branch 0 taken 13335 times.
✓ Branch 1 taken 83433 times.
96768 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14422 96768 }
14423 //Keese and bat halt rates.
14424
3/4
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 215552 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96768 times.
312320 if ( guyversion < 42 && guy_cversion < 4 )
14425 {
14426
14427
2/2
✓ Branch 0 taken 95530 times.
✓ Branch 1 taken 1238 times.
96768 if ( tempguy.family == eeKEESE )
14428 {
14429
14430
2/2
✓ Branch 0 taken 349 times.
✓ Branch 1 taken 889 times.
1238 if ( !tempguy.attributes[0] )
14431 {
14432 889 tempguy.attributes[15] = 120;
14433 889 tempguy.attributes[16] = 16;
14434
14435 889 }
14436 1238 }
14437
2/2
✓ Branch 0 taken 96325 times.
✓ Branch 1 taken 443 times.
96768 if ( tempguy.family == eePEAHAT )
14438 {
14439 443 tempguy.attributes[15] = 80;
14440 443 tempguy.attributes[16] = 16;
14441 443 }
14442
2/2
✓ Branch 0 taken 96579 times.
✓ Branch 1 taken 189 times.
96768 if ( tempguy.family == eeGHINI )
14443 {
14444 189 tempguy.attributes[15] = 120;
14445 189 tempguy.attributes[16] = 10;
14446 189 }
14447
14448
14449 96768 }
14450
14451
14452 //miscellaneous other corrections
14453 //fix the mirror wizzrobe -DD
14454
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(guyversion < 7)
14455 {
14456 if(i == eMWIZ)
14457 {
14458 tempguy.attributes[1] = 0;
14459 tempguy.attributes[3] = 1;
14460 }
14461 }
14462
14463
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(guyversion < 8)
14464 {
14465 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14466 {
14467 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14468 tempguy.attributes[4] = 4; //neck length in segments
14469 tempguy.attributes[5] = 8; //neck offset from first body tile
14470 tempguy.attributes[6] = 40; //offset for each subsequent neck tile from the first neck tile
14471 tempguy.attributes[7] = 168; //head offset from first body tile
14472 tempguy.attributes[8] = 228; //flying head offset from first body tile
14473
14474 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14475 {
14476 tempguy.attributes[5] += 10; //neck offset from first body tile
14477 tempguy.attributes[7] -= 12; //head offset from first body tile
14478 }
14479 }
14480 }
14481
14482
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14483 {
14484 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.attributes[0]==0)
14485 tempguy.bosspal = spDIG;
14486 }
14487
14488
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(guyversion < 11) // December 2007 - Spinning Tile fix
14489 {
14490 if(tempguy.family==eeSPINTILE)
14491 {
14492 tempguy.flags |= guy_superman;
14493 tempguy.item_set = 0; // Don't drop items
14494 tempguy.step = 300;
14495 }
14496 }
14497
14498
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14499 {
14500 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14501 {
14502 if(tempguy.family==eeROPE)
14503 {
14504 tempguy.flags2 &= ~guy_flashing;
14505 }
14506 }
14507
14508 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14509 {
14510 if(tempguy.family==eeBUBBLE)
14511 {
14512 tempguy.flags2 &= ~guy_flashing;
14513 }
14514 }
14515
14516 if((tempguy.family==eeGHINI)&&(tempguy.attributes[0]))
14517 {
14518 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14519 {
14520 tempguy.flags2 |= guy_blinking;
14521 }
14522
14523 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14524 {
14525 tempguy.flags2 |= guy_transparent;
14526 }
14527 }
14528 }
14529
14530
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14531 {
14532 if(i==gFIRE)
14533 {
14534 tempguy.e_anim = aFLIP;
14535 tempguy.e_frate = 24;
14536 }
14537
14538 if(i==gFAIRY)
14539 {
14540 tempguy.e_anim = a2FRM;
14541 tempguy.e_frate = 16;
14542 }
14543 }
14544
14545
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14546 {
14547 if(i==0) Z_message("Updating guys to version 16...\n");
14548
14549 update_guy_1(&tempguy);
14550
14551 if(i==eMPOLSV)
14552 {
14553 tempguy.defense[edefARROW] = edCHINK;
14554 tempguy.defense[edefMAGIC] = ed1HKO;
14555 tempguy.defense[edefREFMAGIC] = ed1HKO;
14556 }
14557 }
14558
14559
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(guyversion < 17) // December 2009
14560 {
14561 if(tempguy.family==eePROJECTILE)
14562 {
14563 tempguy.attributes[0] = 0;
14564 }
14565 }
14566
14567
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(guyversion < 18) // January 2010
14568 {
14569 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
14570 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
14571
14572 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
14573 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.attributes[9] == 0)) ? WAV_GASP : WAV_EDEAD;
14574
14575 if(tempguy.family == eeAQUA)
14576 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
14577 else if(tempguy.family == eeMANHAN)
14578 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
14579 else if(tempguy.family==eePATRA)
14580 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14581 else if(tempguy.family==eeGHOMA)
14582 {
14583 for(int32_t j=0; j<edefLAST; j++)
14584 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
14585
14586 tempguy.defense[edefARROW] = ((tempguy.attributes[0]==3) ? edCHINKL8 : (tempguy.attributes[0]==2) ? edCHINKL4 : 0);
14587
14588 if(tempguy.attributes[0]==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
14589
14590 tempguy.attributes[0]--;
14591 }
14592 else if(tempguy.family == eeGLEEOK)
14593 {
14594 for(int32_t j=0; j<edefLAST; j++)
14595 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14596
14597 if(tempguy.attributes[2]==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
14598 }
14599 else if(tempguy.family == eeARMOS)
14600 {
14601 tempguy.family=eeWALK;
14602 tempguy.hrate = 0;
14603 tempguy.attributes[9] = tempguy.attributes[0];
14604 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] = tempguy.attributes[6] = tempguy.attributes[7] = 0;
14605 tempguy.attributes[8] = e9tARMOS;
14606 }
14607 else if(tempguy.family == eeGHINI && !tempguy.attributes[0])
14608 {
14609 tempguy.family=eeWALK;
14610 tempguy.hrate = 0;
14611 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] =
14612 tempguy.attributes[6] = tempguy.attributes[7] = tempguy.attributes[8] = tempguy.attributes[9] = 0;
14613 }
14614
14615 // Spawn animation flags
14616 if(tempguy.family == eeWALK && (tempguy.flags2&guy_armos || tempguy.flags2&guy_ghini))
14617 tempguy.flags |= guy_fade_flicker;
14618 else
14619 tempguy.flags &= (guy_flags)0x0F00000F; // Get rid of the unused flags!
14620 }
14621
14622
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(guyversion < 20) // April 2010
14623 {
14624 if(tempguy.family == eeTRAP)
14625 {
14626 tempguy.attributes[1] = tempguy.attributes[9];
14627
14628 if(tempguy.attributes[9]>=1)
14629 {
14630 tempguy.attributes[0]++;
14631 }
14632
14633 tempguy.attributes[9] = 0;
14634 }
14635
14636 // Bomb Blast fix
14637 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
14638 tempguy.weapon = ewLitBomb;
14639 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
14640 tempguy.weapon = ewLitSBomb;
14641 }
14642
14643
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(guyversion < 21) // September 2011
14644 {
14645 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
14646 {
14647 if(tempguy.family == eeKEESETRIB)
14648 {
14649 tempguy.family = eeKEESE;
14650 tempguy.attributes[1] = e2tKEESETRIB;
14651 tempguy.attributes[0] = 0;
14652 }
14653
14654 tempguy.rate = 2;
14655 tempguy.hrate = 8;
14656 tempguy.homing = 0;
14657 tempguy.step= (tempguy.family == eeKEESE && tempguy.attributes[0] ? 100:62);
14658 }
14659 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
14660 {
14661 if(tempguy.family == eePEAHAT)
14662 {
14663 tempguy.rate = 4;
14664 tempguy.step = 62;
14665 }
14666 else
14667 tempguy.step = 25;
14668
14669 tempguy.hrate = 8;
14670 tempguy.homing = 0;
14671 }
14672 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
14673 {
14674 if(tempguy.family == eeMANHAN)
14675 tempguy.step=50;
14676
14677 tempguy.hrate = 16;
14678 tempguy.homing = 0;
14679 }
14680 else if(tempguy.family == eeGLEEOK)
14681 {
14682 tempguy.rate = 2;
14683 tempguy.homing = 0;
14684 tempguy.hrate = 9;
14685 tempguy.step=89;
14686 }
14687 else if(tempguy.family == eeGHINI)
14688 {
14689 tempguy.rate = 4;
14690 tempguy.hrate = 12;
14691 tempguy.step=62;
14692 tempguy.homing = 0;
14693 }
14694
14695 // Bigdig random rate fix
14696 if(tempguy.family==eeDIG && tempguy.attributes[9]==1)
14697 {
14698 tempguy.rate = 2;
14699 }
14700 }
14701
14702
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(guyversion < 24) // November 2012
14703 {
14704 if(tempguy.family==eeLANM)
14705 tempguy.attributes[2] = 1;
14706 else if(tempguy.family==eeMOLD)
14707 tempguy.attributes[1] = 0;
14708 }
14709
14710
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 96768 times.
312320 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
14711 {
14712
2/2
✓ Branch 0 taken 1339 times.
✓ Branch 1 taken 95429 times.
96768 if(tempguy.family!=eeDIG)
14713 {
14714 95429 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
14715 95429 }
14716
14717 96768 }
14718 // does not seem to solve the issue!
14719
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if ( Header->zelda_version <= 0x210 )
14720 {
14721 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
14722 if ( tempguy.family == eeDONGO )
14723 {
14724 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
14725 }
14726 }
14727
14728
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 96768 times.
312320 if(guyversion >= 42)
14729 {
14730
2/2
✓ Branch 0 taken 212992 times.
✓ Branch 1 taken 2560 times.
215552 if(guyversion >= 47)
14731 {
14732
1/2
✓ Branch 0 taken 212992 times.
✗ Branch 1 not taken.
212992 if(!p_igetl(&(tempguy.moveflags),f))
14733 {
14734 return qe_invalid;
14735 }
14736 212992 }
14737 else
14738 {
14739 byte fl;
14740
1/2
✓ Branch 0 taken 2560 times.
✗ Branch 1 not taken.
2560 if(!p_getc(&fl,f))
14741 {
14742 return qe_invalid;
14743 }
14744 2560 tempguy.moveflags = (move_flags)fl;
14745 }
14746 215552 }
14747 else
14748 {
14749
7/8
✓ Branch 0 taken 2771 times.
✓ Branch 1 taken 76150 times.
✓ Branch 2 taken 2607 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 922 times.
✓ Branch 5 taken 611 times.
✓ Branch 6 taken 475 times.
✓ Branch 7 taken 13232 times.
96768 switch(tempguy.family)
14750 {
14751 //No gravity; floats over pits
14752 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
14753 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
14754 //Special (bosses, etc)
14755 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
14756 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
14757 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
14758 76150 tempguy.moveflags = move_can_pitwalk;
14759 76150 break;
14760 //No gravity, but falls in pits
14761 case eeLEV:
14762 922 tempguy.moveflags = move_can_pitfall;
14763 922 break;
14764 //Bosses that respect pits
14765 case eeDONGO:
14766 611 tempguy.moveflags = move_obeys_grav;
14767 611 break;
14768 case eeLANM:
14769 475 tempguy.moveflags = move_none;
14770 475 break;
14771 //Gravity, floats over pits
14772 case eeWIZZ: case eeWALLM: case eeGHINI:
14773 2607 tempguy.moveflags = move_obeys_grav | move_can_pitwalk;
14774 2607 break;
14775 //Gravity and falls in pits
14776 case eeWALK:
14777
4/4
✓ Branch 0 taken 12569 times.
✓ Branch 1 taken 663 times.
✓ Branch 2 taken 508 times.
✓ Branch 3 taken 12061 times.
13232 if (tempguy.attributes[8]==e9tPOLSVOICE||tempguy.attributes[8]==e9tVIRE)
14778 1171 break;
14779 [[fallthrough]];
14780 case eeOTHER:
14781 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
14782 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
14783 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
14784 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
14785 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
14786 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
14787 14832 tempguy.moveflags = move_obeys_grav | move_can_pitfall;
14788 14832 }
14789 }
14790
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 96768 times.
312320 if(guyversion < 43)
14791 {
14792
2/2
✓ Branch 0 taken 78757 times.
✓ Branch 1 taken 18011 times.
96768 switch(tempguy.family)
14793 {
14794 //No gravity; floats over pits
14795 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
14796 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
14797 //Special (bosses, etc)
14798 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
14799 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
14800 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
14801 case eeWIZZ: case eeWALLM: case eeGHINI:
14802 //Gravity, floats over pits
14803 78757 tempguy.moveflags |= move_can_waterwalk;
14804 78757 tempguy.moveflags |= move_can_pitwalk;
14805 78757 break;
14806 }
14807 96768 }
14808
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 96768 times.
312320 if (guyversion < 44)
14809 {
14810
2/2
✓ Branch 0 taken 95897 times.
✓ Branch 1 taken 871 times.
96768 if ( tempguy.family == eeGHOMA )
14811 {
14812 871 tempguy.flags |= guy_fade_instant;
14813 871 }
14814 96768 }
14815
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 96768 times.
312320 if (guyversion > 44)
14816 {
14817
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_getc(&(tempguy.spr_shadow),f))
14818 {
14819 return qe_invalid;
14820 }
14821
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_getc(&(tempguy.spr_death),f))
14822 {
14823 return qe_invalid;
14824 }
14825
1/2
✓ Branch 0 taken 215552 times.
✗ Branch 1 not taken.
215552 if(!p_getc(&(tempguy.spr_spawn),f))
14826 {
14827 return qe_invalid;
14828 }
14829 215552 }
14830 else
14831 {
14832
2/2
✓ Branch 0 taken 96392 times.
✓ Branch 1 taken 376 times.
96768 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.attributes[9]==1) ? iwLargeShadow : iwShadow;
14833 96768 tempguy.spr_death = iwDeath;
14834 96768 tempguy.spr_spawn = iwSpawn;
14835 }
14836
14837
2/2
✓ Branch 0 taken 215552 times.
✓ Branch 1 taken 96768 times.
312320 if(guyversion < 46)
14838 {
14839
4/4
✓ Branch 0 taken 13232 times.
✓ Branch 1 taken 83536 times.
✓ Branch 2 taken 12569 times.
✓ Branch 3 taken 663 times.
96768 if(tempguy.family == eeWALK && tempguy.attributes[8] == e9tPOLSVOICE)
14840 {
14841 663 tempguy.moveflags |= move_can_waterwalk;
14842 663 }
14843 96768 }
14844
14845
2/2
✓ Branch 0 taken 212992 times.
✓ Branch 1 taken 99328 times.
312320 if (guyversion < 47)
14846 {
14847
4/4
✓ Branch 0 taken 1369 times.
✓ Branch 1 taken 97959 times.
✓ Branch 2 taken 816 times.
✓ Branch 3 taken 553 times.
99328 if (tempguy.family == eeDIG && tempguy.attributes[9]!=1)
14848 {
14849 553 tempguy.flags2 |= guy_ignore_kill_all;
14850 553 }
14851 99328 }
14852
14853
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 292864 times.
312320 if (guyversion < 48)
14854 {
14855
8/8
✓ Branch 0 taken 33846 times.
✓ Branch 1 taken 259018 times.
✓ Branch 2 taken 32717 times.
✓ Branch 3 taken 1129 times.
✓ Branch 4 taken 31576 times.
✓ Branch 5 taken 1141 times.
✓ Branch 6 taken 1185 times.
✓ Branch 7 taken 30391 times.
292864 if (tempguy.family == eeWALK && (tempguy.attributes[6]==e7tPERMJINX || tempguy.attributes[6]==e7tTEMPJINX || tempguy.attributes[6]==e7tUNJINX)) //BUBBLE CHECK
14856 {
14857
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1696 times.
✓ Branch 2 taken 1699 times.
✓ Branch 3 taken 60 times.
3455 switch (tempguy.attributes[7]) {
14858 case 0: //Sword
14859 1696 tempguy.attributes[7] = e8tSWORD;
14860 1696 break;
14861 case 1: //Item
14862 1699 tempguy.attributes[7] = e8tITEM;
14863 1699 break;
14864 case 2: //Both
14865 60 tempguy.attributes[7] = e8tSWORD|e8tITEM;
14866 60 break;
14867 default: //this can actually happen since Misc8 can be set to any number.
14868 tempguy.attributes[7] = 0;
14869 break;
14870 }
14871 3455 }
14872 292864 }
14873
14874
1/2
✓ Branch 0 taken 312320 times.
✗ Branch 1 not taken.
312320 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
14875 {
14876 tempguy.script = 0;
14877 for(int q = 0; q < 8; ++q)
14878 tempguy.initD[q] = 0;
14879 }
14880 312320 guysbuf[i] = tempguy;
14881 312320 }
14882 610 }
14883
14884 610 return 0;
14885 692 }
14886
14887 void update_guy_1(guydata *tempguy) // November 2009
14888 {
14889 bool doesntcount = false;
14890 tempguy->flags &= ~guy_weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
14891
14892 switch(tempguy->family)
14893 {
14894 case 1: //eeWALK
14895 switch(tempguy->attributes[9])
14896 {
14897 case 0: //Stalfos
14898 if(tempguy->attributes[0]==1) // Fires four projectiles at once
14899 tempguy->attributes[0]=4;
14900
14901 break;
14902
14903 case 1: //Darknut
14904 goto darknuts;
14905 break;
14906 }
14907
14908 tempguy->attributes[9] = 0;
14909 break;
14910
14911 case 2: //eeSHOOT
14912 tempguy->family = eeWALK;
14913
14914 switch(tempguy->attributes[9])
14915 {
14916 case 0: //Octorok
14917 if(tempguy->attributes[0]==1||tempguy->attributes[0]==2)
14918 {
14919 tempguy->attributes[0]=e1tFIREOCTO;
14920 tempguy->attributes[1]=e2tFIREOCTO;
14921 }
14922 else tempguy->attributes[0] = 0;
14923
14924 tempguy->attributes[5]=tempguy->attributes[3];
14925 tempguy->attributes[3]=tempguy->attributes[2];
14926 tempguy->attributes[2]=0;
14927 break;
14928
14929 case 1: // Moblin
14930 tempguy->attributes[0] = 0;
14931 break;
14932
14933 case 2: //Lynel
14934 tempguy->attributes[5]=tempguy->attributes[0]+1;
14935 tempguy->attributes[0]=0;
14936 break;
14937
14938 case 3: //Stalfos 2
14939 if(tempguy->attributes[0]==1) // Fires four projectiles at once
14940 tempguy->attributes[0]=e1t4SHOTS;
14941 else tempguy->attributes[0] = 0;
14942
14943 break;
14944
14945 case 4: //Darknut 5
14946 darknuts:
14947 tempguy->defense[edefFIRE] = edIGNORE;
14948 tempguy->defense[edefBRANG] = edSTUNORCHINK;
14949 tempguy->defense[edefHOOKSHOT] = 0;
14950 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
14951 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
14952
14953 if(tempguy->attributes[0]==1)
14954 tempguy->attributes[0]=2;
14955 else if(tempguy->attributes[0]==2)
14956 {
14957 tempguy->attributes[3]=tempguy->attributes[2];
14958 tempguy->attributes[2]=tempguy->attributes[1];
14959 tempguy->attributes[1]=e2tSPLIT;
14960 tempguy->attributes[0] = 0;
14961 }
14962 else tempguy->attributes[0] = 0;
14963
14964 tempguy->flags |= guy_shield_front;
14965
14966 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
14967 tempguy->flags |= guy_bkshield;
14968
14969 break;
14970 }
14971
14972 tempguy->attributes[9] = 0;
14973 break;
14974
14975 /*
14976 case 9: //eeARMOS
14977 tempguy->family = eeWALK;
14978 break;
14979 */
14980 case 11: //eeGEL
14981 case 33: //eeGELTRIB
14982 if(tempguy->family==33)
14983 {
14984 tempguy->attributes[3] = 1;
14985
14986 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
14987 tempguy->attributes[2] = tempguy->attributes[1];
14988
14989 tempguy->attributes[1] = e2tTRIBBLE;
14990 }
14991 else
14992 {
14993 tempguy->attributes[3] = 0;
14994 tempguy->attributes[2] = 0;
14995 tempguy->attributes[1] = 0;
14996 }
14997
14998 tempguy->family = eeWALK;
14999
15000 if(tempguy->attributes[0])
15001 {
15002 tempguy->attributes[0]=1;
15003 tempguy->weapon = ewFireTrail;
15004 }
15005
15006 break;
15007
15008 case 34: //eeZOLTRIB
15009 case 12: //eeZOL
15010 tempguy->attributes[3]=tempguy->attributes[2];
15011 tempguy->attributes[2]=tempguy->attributes[1];
15012 tempguy->family = eeWALK;
15013 tempguy->attributes[1]=e2tSPLITHIT;
15014
15015 if(tempguy->attributes[0])
15016 {
15017 tempguy->attributes[0]=1;
15018 tempguy->weapon = ewFireTrail;
15019 }
15020
15021 break;
15022
15023 case 13: //eeROPE
15024 tempguy->family = eeWALK;
15025 tempguy->attributes[8] = e9tROPE;
15026
15027 if(tempguy->attributes[0])
15028 {
15029 tempguy->attributes[3] = tempguy->attributes[2];
15030 tempguy->attributes[2] = tempguy->attributes[1];
15031 tempguy->attributes[1] = e2tBOMBCHU;
15032 }
15033
15034 tempguy->attributes[0] = 0;
15035 break;
15036
15037 case 14: //eeGORIYA
15038 tempguy->family = eeWALK;
15039
15040 if(tempguy->attributes[0]!=2) tempguy->attributes[0] = 0;
15041
15042 break;
15043
15044 case 17: //eeBUBBLE
15045 tempguy->family = eeWALK;
15046 tempguy->attributes[7] = tempguy->attributes[1];
15047 tempguy->attributes[6] = tempguy->attributes[0] + 1;
15048 tempguy->attributes[0] = tempguy->attributes[1] = 0;
15049
15050 //fallthrogh
15051 case eeTRAP:
15052 case eeROCK:
15053 doesntcount = true;
15054 break;
15055
15056 case 35: //eeVIRETRIB
15057 case 18: //eeVIRE
15058 tempguy->family = eeWALK;
15059 tempguy->attributes[3]=tempguy->attributes[2];
15060 tempguy->attributes[2]=tempguy->attributes[1];
15061 tempguy->attributes[1]=e2tSPLITHIT;
15062 tempguy->attributes[8]=e9tVIRE;
15063 break;
15064
15065 case 19: //eeLIKE
15066 tempguy->family = eeWALK;
15067 tempguy->attributes[6] = e7tEATITEMS;
15068 tempguy->attributes[7]=95;
15069 break;
15070
15071 case 20: //eePOLSV
15072 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15073 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15074 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15075 tempguy->defense[edefARROW] = ed1HKO;
15076 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15077 tempguy->family = eeWALK;
15078 tempguy->attributes[8] = e9tPOLSVOICE;
15079 tempguy->rate = 4;
15080 tempguy->homing = 32;
15081 tempguy->hrate = 10;
15082 tempguy->grumble = 0;
15083 break;
15084
15085 case eeWIZZ:
15086 if(tempguy->attributes[3])
15087 {
15088 for(int32_t i=0; i < edefLAST; i++)
15089 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15090 }
15091 else
15092 {
15093 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15094 tempguy->defense[edefMAGIC] = edCHINK;
15095 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15096 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15097 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15098 }
15099
15100 break;
15101
15102 case eePEAHAT:
15103 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15104
15105 if(!(tempguy->flags & guy_bhit))
15106 tempguy->defense[edefBRANG] = edSTUNONLY;
15107
15108 break;
15109
15110 case eeLEV:
15111 tempguy->defense[edefSTOMP] = edCHINK;
15112 break;
15113 }
15114
15115 // Old flags
15116 if(tempguy->flags & guy_superman)
15117 {
15118 for(int32_t i = 0; i < edefLAST; i++)
15119 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15120 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15121 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15122 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15123 }
15124
15125 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15126
15127 if(doesntcount)
15128 tempguy->flags |= (guy_doesnt_count);
15129 }
15130
15131
15132 1154920 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version)
15133 {
15134 byte tempbyte, padding;
15135 int32_t extras, secretcombos;
15136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_getc(&(temp_mapscr->valid),f))
15137 {
15138 return qe_invalid;
15139 }
15140
15141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_getc(&(temp_mapscr->guy),f))
15142 return qe_invalid;
15143 1154920 temp_mapscr->guytile = -1; //signal to use default guy values
15144
2/2
✓ Branch 0 taken 1154343 times.
✓ Branch 1 taken 577 times.
1154920 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
15145
4/4
✓ Branch 0 taken 577 times.
✓ Branch 1 taken 1154343 times.
✓ Branch 2 taken 42 times.
✓ Branch 3 taken 535 times.
1154920 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
15146
15147
5/6
✓ Branch 0 taken 1132744 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1130024 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1154920 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15148 {
15149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
22176 if(!p_getc(&tempbyte,f))
15150 {
15151 return qe_invalid;
15152 }
15153
15154 22176 temp_mapscr->str=tempbyte;
15155 22176 }
15156 else
15157 {
15158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1132744 times.
1132744 if(!p_igetw(&(temp_mapscr->str),f))
15159 {
15160 return qe_invalid;
15161 }
15162 }
15163
15164
1/2
✓ Branch 0 taken 1154920 times.
✗ Branch 1 not taken.
1154920 if(!p_getc(&(temp_mapscr->room),f))
15165 {
15166 return qe_invalid;
15167 }
15168
15169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_getc(&(temp_mapscr->item),f))
15170 {
15171 return qe_invalid;
15172 }
15173
15174
3/6
✓ Branch 0 taken 626416 times.
✓ Branch 1 taken 528504 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 626416 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1154920 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15175 {
15176 528504 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15177 528504 }
15178 else
15179 {
15180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626416 times.
626416 if(!p_getc(&(temp_mapscr->hasitem),f))
15181 return qe_invalid;
15182 }
15183
15184
3/4
✓ Branch 0 taken 1132744 times.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1157640 if((Header->zelda_version < 0x192)||
15185
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1130024 times.
1132744 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15186 {
15187
1/2
✓ Branch 0 taken 22176 times.
✗ Branch 1 not taken.
22176 if(!p_getc(&tempbyte,f))
15188 {
15189 return qe_invalid;
15190 }
15191 22176 }
15192
15193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f))
15194 {
15195 return qe_invalid;
15196 }
15197
15198
2/2
✓ Branch 0 taken 1130024 times.
✓ Branch 1 taken 24896 times.
1154920 if(Header->zelda_version < 0x193)
15199 {
15200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24896 times.
24896 if(!p_getc(&tempbyte,f))
15201 {
15202 return qe_invalid;
15203 }
15204 24896 }
15205
15206
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15207 {
15208
2/2
✓ Branch 0 taken 1879248 times.
✓ Branch 1 taken 626416 times.
2505664 for(int32_t i=1; i<4; i++)
15209 {
15210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1879248 times.
1879248 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
15211 {
15212 return qe_invalid;
15213 }
15214 1879248 }
15215 626416 }
15216 else
15217 {
15218 528504 temp_mapscr->tilewarptype[1]=0;
15219 528504 temp_mapscr->tilewarptype[2]=0;
15220 528504 temp_mapscr->tilewarptype[3]=0;
15221 }
15222
15223
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1130024 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15224 {
15225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1132744 times.
1132744 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
15226 {
15227 return qe_invalid;
15228 }
15229 1132744 }
15230
15231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f))
15232 {
15233 return qe_invalid;
15234 }
15235
15236 1154920 temp_mapscr->warpreturnx[1]=0;
15237 1154920 temp_mapscr->warpreturnx[2]=0;
15238 1154920 temp_mapscr->warpreturnx[3]=0;
15239
15240
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15241 {
15242
2/2
✓ Branch 0 taken 1879248 times.
✓ Branch 1 taken 626416 times.
2505664 for(int32_t i=1; i<4; i++)
15243 {
15244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1879248 times.
1879248 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
15245 {
15246 return qe_invalid;
15247 }
15248 1879248 }
15249 626416 }
15250
15251
1/2
✓ Branch 0 taken 1154920 times.
✗ Branch 1 not taken.
1154920 if(!p_getc(&(temp_mapscr->warpreturny[0]),f))
15252 {
15253 return qe_invalid;
15254 }
15255
15256 1154920 temp_mapscr->warpreturny[1]=0;
15257 1154920 temp_mapscr->warpreturny[2]=0;
15258 1154920 temp_mapscr->warpreturny[3]=0;
15259
15260
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15261 {
15262
2/2
✓ Branch 0 taken 1879248 times.
✓ Branch 1 taken 626416 times.
2505664 for(int32_t i=1; i<4; i++)
15263 {
15264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1879248 times.
1879248 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
15265 {
15266 return qe_invalid;
15267 }
15268 1879248 }
15269
15270
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(version>=18)
15271 {
15272
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_igetw(&temp_mapscr->warpreturnc,f))
15273 {
15274 return qe_invalid;
15275 }
15276 626416 }
15277 else
15278 {
15279 byte temp;
15280
15281 if(!p_getc(&temp,f))
15282 {
15283 return qe_invalid;
15284 }
15285
15286 temp_mapscr->warpreturnc=temp<<8|temp;
15287 }
15288 626416 }
15289
15290
1/2
✓ Branch 0 taken 1154920 times.
✗ Branch 1 not taken.
1154920 if(!p_getc(&(temp_mapscr->stairx),f))
15291
15292 {
15293 return qe_invalid;
15294 }
15295
15296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_getc(&(temp_mapscr->stairy),f))
15297 {
15298 return qe_invalid;
15299 }
15300
15301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_getc(&(temp_mapscr->itemx),f))
15302 {
15303 return qe_invalid;
15304 }
15305
15306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_getc(&(temp_mapscr->itemy),f))
15307 {
15308 return qe_invalid;
15309 }
15310
15311
2/2
✓ Branch 0 taken 626416 times.
✓ Branch 1 taken 528504 times.
1154920 if(version > 15) // February 2009
15312 {
15313
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_igetw(&(temp_mapscr->color),f))
15314 {
15315 return qe_invalid;
15316 }
15317 626416 }
15318 else
15319 {
15320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 528504 times.
528504 if(!p_getc(& tempbyte,f))
15321 {
15322 return qe_invalid;
15323 }
15324
15325 528504 temp_mapscr->color = (word) tempbyte;
15326 }
15327
15328
1/2
✓ Branch 0 taken 1154920 times.
✗ Branch 1 not taken.
1154920 if(!p_getc(&(temp_mapscr->enemyflags),f))
15329 {
15330 return qe_invalid;
15331 }
15332
15333
2/2
✓ Branch 0 taken 4619680 times.
✓ Branch 1 taken 1154920 times.
5774600 for(int32_t k=0; k<4; k++)
15334 {
15335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4619680 times.
4619680 if(!p_getc(&(temp_mapscr->door[k]),f))
15336 {
15337 return qe_invalid;
15338
15339 }
15340 4619680 }
15341
15342
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
1154920 if(version <= 11)
15343 {
15344
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
15345 {
15346 return qe_invalid;
15347 }
15348
15349 528504 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15350
15351
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15352 {
15353 for(int32_t i=1; i<4; i++)
15354 {
15355 if(!p_getc(&(tempbyte),f))
15356 {
15357 return qe_invalid;
15358 }
15359
15360 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15361 }
15362 }
15363 else
15364 {
15365 528504 temp_mapscr->tilewarpdmap[1]=0;
15366 528504 temp_mapscr->tilewarpdmap[2]=0;
15367 528504 temp_mapscr->tilewarpdmap[3]=0;
15368 }
15369 528504 }
15370 else
15371 {
15372
2/2
✓ Branch 0 taken 2505664 times.
✓ Branch 1 taken 626416 times.
3132080 for(int32_t i=0; i<4; i++)
15373 {
15374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2505664 times.
2505664 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
15375 {
15376 return qe_invalid;
15377 }
15378 2505664 }
15379 }
15380
15381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f))
15382 {
15383 return qe_invalid;
15384 }
15385
15386
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15387 {
15388
2/2
✓ Branch 0 taken 1879248 times.
✓ Branch 1 taken 626416 times.
2505664 for(int32_t i=1; i<4; i++)
15389 {
15390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1879248 times.
1879248 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
15391 {
15392 return qe_invalid;
15393 }
15394 1879248 }
15395 626416 }
15396 else
15397 {
15398 528504 temp_mapscr->tilewarpscr[1]=0;
15399 528504 temp_mapscr->tilewarpscr[2]=0;
15400 528504 temp_mapscr->tilewarpscr[3]=0;
15401 }
15402
15403
2/2
✓ Branch 0 taken 626416 times.
✓ Branch 1 taken 528504 times.
1154920 if(version >= 15)
15404 {
15405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626416 times.
626416 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
15406 {
15407 return qe_invalid;
15408 }
15409 626416 }
15410 else
15411 {
15412 528504 temp_mapscr->tilewarpoverlayflags=0;
15413 }
15414
15415
1/2
✓ Branch 0 taken 1154920 times.
✗ Branch 1 not taken.
1154920 if(!p_getc(&(temp_mapscr->exitdir),f))
15416 {
15417 return qe_invalid;
15418 }
15419
15420
2/2
✓ Branch 0 taken 1130024 times.
✓ Branch 1 taken 24896 times.
1154920 if(Header->zelda_version < 0x193)
15421 {
15422
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if(!p_getc(&tempbyte,f))
15423 {
15424 return qe_invalid;
15425 }
15426
15427 24896 }
15428
15429
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1152200 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15430 {
15431 if(!p_getc(&padding,f))
15432 {
15433 return qe_invalid;
15434 }
15435 }
15436
15437
2/2
✓ Branch 0 taken 11549200 times.
✓ Branch 1 taken 1154920 times.
12704120 for(int32_t k=0; k<10; k++)
15438 {
15439 /*
15440 if (!temp_mapscr->enemy[k])
15441 {
15442 continue;
15443 }
15444 */
15445
5/6
✓ Branch 0 taken 11327440 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11300240 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11549200 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15446 {
15447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221760 times.
221760 if(!p_getc(&tempbyte,f))
15448 {
15449 return qe_invalid;
15450 }
15451
15452 221760 temp_mapscr->enemy[k]=tempbyte;
15453 221760 }
15454 else
15455 {
15456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11327440 times.
11327440 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
15457 {
15458 return qe_invalid;
15459 }
15460 }
15461
15462
5/6
✓ Branch 0 taken 11327440 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11300240 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11549200 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15463 {
15464 //using enumerations here is dangerous
15465 //very easy to break old quests -DD
15466
2/2
✓ Branch 0 taken 1342 times.
✓ Branch 1 taken 220418 times.
221760 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15467 {
15468 1342 temp_mapscr->enemy[k]+=5;
15469 1342 }
15470
2/2
✓ Branch 0 taken 220324 times.
✓ Branch 1 taken 94 times.
220418 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15471 {
15472 94 temp_mapscr->enemy[k]+=1;
15473 94 }
15474 221760 }
15475
15476
2/2
✓ Branch 0 taken 6264160 times.
✓ Branch 1 taken 5285040 times.
11549200 if(version < 9)
15477 {
15478
2/2
✓ Branch 0 taken 5009135 times.
✓ Branch 1 taken 275905 times.
5285040 if(temp_mapscr->enemy[k]>0)
15479 {
15480 275905 temp_mapscr->enemy[k]+=10;
15481 275905 }
15482 5285040 }
15483 //don't read in any invalid data
15484
2/2
✓ Branch 0 taken 11548750 times.
✓ Branch 1 taken 450 times.
11549200 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15485 {
15486 450 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15487 450 temp_mapscr->enemy[k] = 0;
15488 450 }
15489 11549200 }
15490
15491
1/2
✓ Branch 0 taken 1154920 times.
✗ Branch 1 not taken.
1154920 if(!p_getc(&(temp_mapscr->pattern),f))
15492 {
15493 return qe_invalid;
15494 }
15495
15496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f))
15497 {
15498 return qe_invalid;
15499 }
15500
15501
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15502 {
15503
2/2
✓ Branch 0 taken 1879248 times.
✓ Branch 1 taken 626416 times.
2505664 for(int32_t i=1; i<4; i++)
15504 {
15505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1879248 times.
1879248 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
15506 {
15507 return qe_invalid;
15508 }
15509 1879248 }
15510 626416 }
15511 else
15512 {
15513 528504 temp_mapscr->sidewarptype[1]=0;
15514 528504 temp_mapscr->sidewarptype[2]=0;
15515 528504 temp_mapscr->sidewarptype[3]=0;
15516 }
15517
15518
2/2
✓ Branch 0 taken 626416 times.
✓ Branch 1 taken 528504 times.
1154920 if(version >= 15)
15519 {
15520
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
15521 {
15522 return qe_invalid;
15523 }
15524 626416 }
15525 else
15526 {
15527 528504 temp_mapscr->sidewarpoverlayflags=0;
15528 }
15529
15530
1/2
✓ Branch 0 taken 1154920 times.
✗ Branch 1 not taken.
1154920 if(!p_getc(&(temp_mapscr->warparrivalx),f))
15531 {
15532 return qe_invalid;
15533 }
15534
15535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_getc(&(temp_mapscr->warparrivaly),f))
15536 {
15537 return qe_invalid;
15538 }
15539
15540
2/2
✓ Branch 0 taken 4619680 times.
✓ Branch 1 taken 1154920 times.
5774600 for(int32_t k=0; k<4; k++)
15541 {
15542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4619680 times.
4619680 if(!p_getc(&(temp_mapscr->path[k]),f))
15543 {
15544 return qe_invalid;
15545 }
15546 4619680 }
15547
15548
1/2
✓ Branch 0 taken 1154920 times.
✗ Branch 1 not taken.
1154920 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f))
15549 {
15550 return qe_invalid;
15551 }
15552
15553
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15554 {
15555
2/2
✓ Branch 0 taken 626416 times.
✓ Branch 1 taken 1879248 times.
2505664 for(int32_t i=1; i<4; i++)
15556 {
15557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1879248 times.
1879248 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
15558 {
15559 return qe_invalid;
15560 }
15561 1879248 }
15562 626416 }
15563 else
15564 {
15565 528504 temp_mapscr->sidewarpscr[1]=0;
15566 528504 temp_mapscr->sidewarpscr[2]=0;
15567 528504 temp_mapscr->sidewarpscr[3]=0;
15568 }
15569
15570
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
1154920 if(version <= 11)
15571 {
15572
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
15573 {
15574 return qe_invalid;
15575 }
15576
15577 528504 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
15578
15579
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15580 {
15581 for(int32_t i=1; i<4; i++)
15582 {
15583 if(!p_getc(&(tempbyte),f))
15584 {
15585 return qe_invalid;
15586 }
15587
15588 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
15589 }
15590 }
15591 else
15592 {
15593 528504 temp_mapscr->sidewarpdmap[1]=0;
15594 528504 temp_mapscr->sidewarpdmap[2]=0;
15595 528504 temp_mapscr->sidewarpdmap[3]=0;
15596 }
15597 528504 }
15598 else
15599 {
15600
2/2
✓ Branch 0 taken 2505664 times.
✓ Branch 1 taken 626416 times.
3132080 for(int32_t i=0; i<4; i++)
15601 {
15602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2505664 times.
2505664 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
15603 {
15604 return qe_invalid;
15605 }
15606 2505664 }
15607 }
15608
15609
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15610 {
15611
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
15612 {
15613 return qe_invalid;
15614 }
15615 626416 }
15616 528504 else temp_mapscr->sidewarpindex = 0;
15617
15618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_igetw(&(temp_mapscr->undercombo),f))
15619 {
15620 return qe_invalid;
15621 }
15622
15623
2/2
✓ Branch 0 taken 1130024 times.
✓ Branch 1 taken 24896 times.
1154920 if(Header->zelda_version < 0x193)
15624 {
15625
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if(!p_getc(&(temp_mapscr->old_cpage),f))
15626 {
15627 return qe_invalid;
15628 }
15629 24896 }
15630
15631
1/2
✓ Branch 0 taken 1154920 times.
✗ Branch 1 not taken.
1154920 if(!p_getc(&(temp_mapscr->undercset),f)) //recalculated for older quests
15632 {
15633 return qe_invalid;
15634 }
15635
15636
1/2
✓ Branch 0 taken 1154920 times.
✗ Branch 1 not taken.
1154920 if(!p_igetw(&(temp_mapscr->catchall),f))
15637 {
15638 return qe_invalid;
15639 }
15640
15641
1/2
✓ Branch 0 taken 1154920 times.
✗ Branch 1 not taken.
1154920 if(!p_getc(&(temp_mapscr->flags),f))
15642 {
15643 return qe_invalid;
15644 }
15645
15646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_getc(&(temp_mapscr->flags2),f))
15647 {
15648 return qe_invalid;
15649 }
15650
15651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_getc(&(temp_mapscr->flags3),f))
15652 {
15653 return qe_invalid;
15654 }
15655
15656
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
15657 //if (version>2)
15658 {
15659
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_getc(&(temp_mapscr->flags4),f))
15660 {
15661 return qe_invalid;
15662 }
15663 626416 }
15664
15665
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15666 {
15667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626416 times.
626416 if(!p_getc(&(temp_mapscr->flags5),f))
15668 {
15669 return qe_invalid;
15670 }
15671
15672
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_igetw(&(temp_mapscr->noreset),f))
15673 {
15674 return qe_invalid;
15675 }
15676
15677
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_igetw(&(temp_mapscr->nocarry),f))
15678 {
15679 return qe_invalid;
15680 }
15681
15682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626416 times.
626416 if(temp_mapscr->flags5&32)
15683 {
15684 temp_mapscr->flags5 &= ~32;
15685 temp_mapscr->noreset |= 48;
15686 }
15687
15688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626416 times.
626416 if(version<8)
15689 {
15690 if(temp_mapscr->noreset&1)
15691 {
15692 temp_mapscr->noreset|=8192;
15693 }
15694
15695 if(temp_mapscr->nocarry&1)
15696 {
15697 temp_mapscr->nocarry|=8192;
15698 temp_mapscr->nocarry&=~1;
15699 }
15700 }
15701 626416 }
15702 else
15703 {
15704 528504 temp_mapscr->flags5 = 0;
15705 528504 temp_mapscr->noreset = 0;
15706 528504 temp_mapscr->nocarry = 0;
15707 }
15708
15709
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
15710 {
15711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626416 times.
626416 if(!p_getc(&(temp_mapscr->flags6),f))
15712 {
15713 return qe_invalid;
15714 }
15715 626416 }
15716
15717
2/2
✓ Branch 0 taken 626416 times.
✓ Branch 1 taken 528504 times.
1154920 if(version>5)
15718 {
15719
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_getc(&(temp_mapscr->flags7),f))
15720 {
15721 return qe_invalid;
15722 }
15723
15724
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_getc(&(temp_mapscr->flags8),f))
15725 {
15726 return qe_invalid;
15727 }
15728
15729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626416 times.
626416 if(!p_getc(&(temp_mapscr->flags9),f))
15730 {
15731 return qe_invalid;
15732 }
15733
15734
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_getc(&(temp_mapscr->flags10),f))
15735 {
15736 return qe_invalid;
15737 }
15738
15739
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_getc(&(temp_mapscr->csensitive),f))
15740 {
15741 return qe_invalid;
15742 }
15743 626416 }
15744 else
15745 {
15746 528504 temp_mapscr->csensitive=1;
15747 }
15748
15749
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
1154920 if(version<14) // August 2007: screen SFX added
15750 {
15751
2/2
✓ Branch 0 taken 527510 times.
✓ Branch 1 taken 994 times.
528504 if(temp_mapscr->flags&8) //fROAR
15752 {
15753 994 temp_mapscr->bosssfx=
15754
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 853 times.
994 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
15755 853 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
15756 WAV_ROAR;
15757 994 }
15758
15759
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 528334 times.
528504 if(temp_mapscr->flags&128) //fSEA
15760 {
15761 170 temp_mapscr->oceansfx=WAV_SEA;
15762 170 }
15763
15764 528504 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
15765 ? 0 : WAV_SECRET;
15766
15767 528504 temp_mapscr->flags3 &= ~66; //64|2
15768 528504 temp_mapscr->flags2 &= ~32;
15769 528504 temp_mapscr->flags &= ~136; // 128|8
15770 528504 }
15771 else
15772 {
15773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626416 times.
626416 if(!p_getc(&(temp_mapscr->oceansfx),f))
15774 {
15775 return qe_invalid;
15776 }
15777
15778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626416 times.
626416 if(!p_getc(&(temp_mapscr->bosssfx),f))
15779 {
15780 return qe_invalid;
15781 }
15782
15783
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_getc(&(temp_mapscr->secretsfx),f))
15784 {
15785 return qe_invalid;
15786 }
15787 }
15788
15789
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
1154920 if(version<15) // October 2007: another SFX
15790 {
15791 528504 temp_mapscr->holdupsfx=WAV_PICKUP;
15792 528504 }
15793 else
15794 {
15795
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_getc(&(temp_mapscr->holdupsfx),f))
15796 {
15797 return qe_invalid;
15798 }
15799 }
15800
15801
15802
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1130024 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
15803 {
15804
2/2
✓ Branch 0 taken 6796464 times.
✓ Branch 1 taken 1132744 times.
7929208 for(int32_t k=0; k<6; k++)
15805 {
15806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6796464 times.
6796464 if(!p_getc(&(temp_mapscr->layermap[k]),f))
15807 {
15808 return qe_invalid;
15809 }
15810 6796464 }
15811
15812
2/2
✓ Branch 0 taken 1132744 times.
✓ Branch 1 taken 6796464 times.
7929208 for(int32_t k=0; k<6; k++)
15813 {
15814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6796464 times.
6796464 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
15815 {
15816 return qe_invalid;
15817 }
15818 6796464 }
15819 1132744 }
15820
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22176 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
15821 {
15822 if(!p_getc(&(temp_mapscr->layermap[2]),f))
15823 {
15824 return qe_invalid;
15825 }
15826
15827 if(!p_getc(&(temp_mapscr->layerscreen[2]),f))
15828 {
15829 return qe_invalid;
15830 }
15831
15832 if(!p_getc(&(temp_mapscr->layermap[4]),f))
15833 {
15834 return qe_invalid;
15835 }
15836
15837 if(!p_getc(&(temp_mapscr->layerscreen[4]),f))
15838
15839 {
15840 return qe_invalid;
15841 }
15842 }
15843
15844
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1152200 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1154920 if((Header->zelda_version == 0x192)&&(Header->build>149))
15845 {
15846
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
15847 {
15848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxsize
15849 {
15850 return qe_invalid;
15851 }
15852 16320 }
15853
15854
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
15855 {
15856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxspeed
15857 {
15858 return qe_invalid;
15859 }
15860 16320 }
15861
15862
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
15863 {
15864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxdelay
15865 {
15866 return qe_invalid;
15867 }
15868 16320 }
15869
15870
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
15871 {
15872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerysize
15873 {
15874 return qe_invalid;
15875 }
15876 16320 }
15877
15878
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
15879 {
15880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layeryspeed
15881 {
15882 return qe_invalid;
15883 }
15884 16320 }
15885
15886
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 16320 times.
19040 for(int32_t k=0; k<6; k++)
15887 {
15888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerydelay
15889 {
15890 return qe_invalid;
15891 }
15892 16320 }
15893 2720 }
15894
15895
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1130024 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
15896 {
15897
2/2
✓ Branch 0 taken 6796464 times.
✓ Branch 1 taken 1132744 times.
7929208 for(int32_t k=0; k<6; k++)
15898 {
15899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6796464 times.
6796464 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
15900 {
15901 return qe_invalid;
15902 }
15903 6796464 }
15904 1132744 }
15905
15906
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1130024 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15907 {
15908
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1130024 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1132744 if((Header->zelda_version == 0x192)&&(Header->build>153))
15909 {
15910
1/2
✓ Branch 0 taken 2720 times.
✗ Branch 1 not taken.
2720 if(!p_getc(&padding,f))
15911 {
15912 return qe_invalid;
15913 }
15914 2720 }
15915
15916
1/2
✓ Branch 0 taken 1132744 times.
✗ Branch 1 not taken.
1132744 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
15917 {
15918 return qe_invalid;
15919 }
15920 1132744 }
15921
15922
5/6
✓ Branch 0 taken 1132744 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1130024 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1154920 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
15923 {
15924 22176 extras=15;
15925 22176 }
15926
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1130024 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1132744 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
15927 {
15928 extras=11;
15929 }
15930
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1130024 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
1132744 else if((Header->zelda_version == 0x192)&&(Header->build<150))
15931 {
15932 extras=32;
15933 }
15934
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1130024 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1132744 else if((Header->zelda_version == 0x192)&&(Header->build<154))
15935 {
15936 extras=64;
15937 }
15938
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1130024 times.
1132744 else if(Header->zelda_version < 0x193)
15939 {
15940 2720 extras=62;
15941 2720 }
15942 else
15943
15944 {
15945 1130024 extras=0;
15946 }
15947
15948
2/2
✓ Branch 0 taken 501280 times.
✓ Branch 1 taken 1154920 times.
1656200 for(int32_t k=0; k<extras; k++)
15949 {
15950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 501280 times.
501280 if(!p_getc(&tempbyte,f)) //extra[k]
15951 {
15952 return qe_invalid;
15953 }
15954 501280 }
15955
15956
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
15957 //if (version>3)
15958 {
15959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626416 times.
626416 if(!p_getc(&(temp_mapscr->nextmap),f))
15960 {
15961 return qe_invalid;
15962 }
15963
15964
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_getc(&(temp_mapscr->nextscr),f))
15965 {
15966 return qe_invalid;
15967 }
15968 626416 }
15969 else
15970 {
15971 528504 temp_mapscr->nextmap=0;
15972 528504 temp_mapscr->nextscr=0;
15973 }
15974
15975
5/6
✓ Branch 0 taken 1132744 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1130024 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1154920 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
15976 {
15977 22176 secretcombos=20;
15978 22176 }
15979
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1130024 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1132744 else if((Header->zelda_version == 0x192)&&(Header->build<154))
15980 {
15981 secretcombos=256;
15982 }
15983 else
15984 {
15985 1132744 secretcombos=128;
15986 }
15987
15988
5/6
✓ Branch 0 taken 1132744 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1130024 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1154920 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
15989 {
15990
2/2
✓ Branch 0 taken 443520 times.
✓ Branch 1 taken 22176 times.
465696 for(int32_t k=0; k<secretcombos; k++)
15991 {
15992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(!p_getc(&tempbyte,f))
15993 {
15994 return qe_invalid;
15995 }
15996
15997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(k<128)
15998 {
15999 443520 temp_mapscr->secretcombo[k]=tempbyte;
16000 443520 }
16001 443520 }
16002 22176 }
16003 else
16004 {
16005
2/2
✓ Branch 0 taken 144991232 times.
✓ Branch 1 taken 1132744 times.
146123976 for(int32_t k=0; k<128; k++)
16006 {
16007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144991232 times.
144991232 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16008 {
16009 return qe_invalid;
16010 }
16011
16012 144991232 }
16013 }
16014
16015
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1130024 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16016 {
16017
2/2
✓ Branch 0 taken 144991232 times.
✓ Branch 1 taken 1132744 times.
146123976 for(int32_t k=0; k<128; k++)
16018 {
16019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144991232 times.
144991232 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16020 {
16021 return qe_invalid;
16022 }
16023 144991232 }
16024
16025
2/2
✓ Branch 0 taken 144991232 times.
✓ Branch 1 taken 1132744 times.
146123976 for(int32_t k=0; k<128; k++)
16026 {
16027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144991232 times.
144991232 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16028 {
16029 return qe_invalid;
16030 }
16031 144991232 }
16032 1132744 }
16033
16034
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1152200 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16035 {
16036 if(!p_getc(&padding,f))
16037 {
16038 return qe_invalid;
16039 }
16040 }
16041
16042
2/2
✓ Branch 0 taken 203265920 times.
✓ Branch 1 taken 1154920 times.
204420840 for(int32_t k=0; k<176; k++)
16043 {
16044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203265920 times.
203265920 if(!p_igetw(&(temp_mapscr->data[k]),f))
16045 {
16046 return qe_invalid;
16047 }
16048 203265920 }
16049
16050
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1152200 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16051 {
16052 if(!p_getc(&padding,f))
16053 {
16054 return qe_invalid;
16055 }
16056
16057 if(!p_getc(&padding,f))
16058 {
16059 return qe_invalid;
16060 }
16061 }
16062
16063
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1130024 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16064 {
16065
2/2
✓ Branch 0 taken 199362944 times.
✓ Branch 1 taken 1132744 times.
200495688 for(int32_t k=0; k<176; k++)
16066 {
16067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 199362944 times.
199362944 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16068 {
16069 return qe_invalid;
16070 }
16071
16072
3/4
✓ Branch 0 taken 478720 times.
✓ Branch 1 taken 198884224 times.
✓ Branch 2 taken 478720 times.
✗ Branch 3 not taken.
199362944 if((Header->zelda_version == 0x192)&&(Header->build<24))
16073 {
16074 if(!p_getc(&tempbyte,f))
16075 {
16076 return qe_invalid;
16077 }
16078
16079 if(!p_getc(&tempbyte,f))
16080 {
16081 return qe_invalid;
16082 }
16083
16084 if(!p_getc(&tempbyte,f))
16085 {
16086 return qe_invalid;
16087 }
16088 }
16089 199362944 }
16090 1132744 }
16091
16092
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1130024 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16093 {
16094
2/2
✓ Branch 0 taken 1132744 times.
✓ Branch 1 taken 199362944 times.
200495688 for(int32_t k=0; k<176; k++)
16095 {
16096
16097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 199362944 times.
199362944 if(!p_getc(&(temp_mapscr->cset[k]),f))
16098 {
16099 return qe_invalid;
16100 }
16101 199362944 }
16102 1132744 }
16103
16104
5/6
✓ Branch 0 taken 1132744 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1130024 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1154920 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16105 {
16106 22176 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16107 22176 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16108 22176 }
16109
16110
5/6
✓ Branch 0 taken 1132744 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1130024 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1154920 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16111 {
16112 22176 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16113 22176 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16114 22176 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16115 22176 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16116 22176 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16117 22176 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16118 22176 }
16119
16120
5/6
✓ Branch 0 taken 1132744 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1130024 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1154920 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16121 {
16122
2/2
✓ Branch 0 taken 3902976 times.
✓ Branch 1 taken 22176 times.
3925152 for(int32_t k=0; k<176; k++)
16123 {
16124
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version == 0x192)&&(Header->build>149))
16125 {
16126 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16127 {
16128 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16129 }
16130 }
16131 else
16132 {
16133
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version < 0x192)||
16134 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16135 {
16136 3902976 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16137 3902976 }
16138
16139 3902976 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16140 }
16141
16142 3902976 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16143 3902976 }
16144 22176 }
16145
16146 /*if(version>12)
16147 {
16148 if(!p_getc(&(temp_mapscr->scrWidth),f))
16149 {
16150 return qe_invalid;
16151 }
16152 if(!p_getc(&(temp_mapscr->scrHeight),f))
16153 {
16154 return qe_invalid;
16155 }
16156 }*/
16157
16158
2/2
✓ Branch 0 taken 626416 times.
✓ Branch 1 taken 528504 times.
1154920 if(version>4)
16159 {
16160
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16161 {
16162 return qe_invalid;
16163 }
16164 626416 }
16165 else
16166 {
16167 528504 temp_mapscr->screen_midi = -1;
16168 }
16169
16170
2/2
✓ Branch 0 taken 626416 times.
✓ Branch 1 taken 528504 times.
1154920 if(version>=17)
16171 {
16172
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_getc(&(temp_mapscr->lens_layer),f))
16173 {
16174 return qe_invalid;
16175 }
16176 626416 }
16177 else
16178 {
16179 528504 temp_mapscr->lens_layer = llNORMAL;
16180 }
16181
16182
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
1154920 if(version>6)
16183 {
16184 dword bits;
16185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626416 times.
626416 if(!p_igetl(&bits,f))
16186 {
16187 return qe_invalid;
16188 }
16189
16190 int32_t m;
16191 float tempfloat;
16192 word tempw;
16193 626416 temp_mapscr->ffcCountMarkDirty();
16194
16195
2/2
✓ Branch 0 taken 626416 times.
✓ Branch 1 taken 20045312 times.
20671728 for(m=0; m<32; m++)
16196 {
16197 20045312 ffcdata& tempffc = temp_mapscr->ffcs[m];
16198 20045312 tempffc.clear();
16199
2/2
✓ Branch 0 taken 19785588 times.
✓ Branch 1 taken 259724 times.
20045312 if((bits>>m)&1)
16200 {
16201
1/2
✓ Branch 0 taken 259724 times.
✗ Branch 1 not taken.
259724 if(!p_igetw(&tempw,f))
16202 {
16203 return qe_invalid;
16204 }
16205 259724 tempffc.data = tempw;
16206
16207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_getc(&(tempffc.cset),f))
16208 {
16209 return qe_invalid;
16210 }
16211
16212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetw(&(tempffc.delay),f))
16213 {
16214 return qe_invalid;
16215 }
16216
16217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(version < 9)
16218 {
16219 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16220 {
16221 return qe_invalid;
16222 }
16223
16224 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16225
16226 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16227 {
16228 return qe_invalid;
16229 }
16230
16231 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16232
16233 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16234 {
16235 return qe_invalid;
16236 }
16237
16238 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16239
16240 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16241 {
16242 return qe_invalid;
16243 }
16244
16245 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16246
16247 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16248 {
16249 return qe_invalid;
16250 }
16251
16252 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16253
16254 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16255 {
16256 return qe_invalid;
16257 }
16258
16259 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16260 }
16261 else
16262 {
16263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetzf(&(tempffc.x),f))
16264 {
16265 return qe_invalid;
16266 }
16267
16268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetzf(&(tempffc.y),f))
16269 {
16270 return qe_invalid;
16271 }
16272
16273
1/2
✓ Branch 0 taken 259724 times.
✗ Branch 1 not taken.
259724 if(!p_igetzf(&(tempffc.vx),f))
16274 {
16275 return qe_invalid;
16276 }
16277
16278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetzf(&(tempffc.vy),f))
16279 {
16280 return qe_invalid;
16281 }
16282
16283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetzf(&(tempffc.ax),f))
16284 {
16285 return qe_invalid;
16286 }
16287
16288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetzf(&(tempffc.ay),f))
16289 {
16290 return qe_invalid;
16291 }
16292 }
16293
16294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_getc(&(tempffc.link),f))
16295 {
16296 return qe_invalid;
16297 }
16298
16299
1/2
✓ Branch 0 taken 259724 times.
✗ Branch 1 not taken.
259724 if(version>7)
16300 {
16301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_getc(&tempbyte,f))
16302 {
16303 return qe_invalid;
16304 }
16305
16306 259724 tempffc.hit_width = (tempbyte&0x3F)+1;
16307 259724 tempffc.txsz = (tempbyte>>6)+1;
16308
16309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_getc(&tempbyte,f))
16310 {
16311 return qe_invalid;
16312 }
16313
16314 259724 tempffc.hit_height = (tempbyte&0x3F)+1;
16315 259724 tempffc.tysz = (tempbyte>>6)+1;
16316
16317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetl(&(tempffc.flags),f))
16318 {
16319 return qe_invalid;
16320 }
16321 259724 }
16322 else
16323 {
16324 tempffc.hit_width=16;
16325 tempffc.hit_height=16;
16326 tempffc.txsz=1;
16327 tempffc.tysz=1;
16328 tempffc.flags=ffc_none;
16329 }
16330
16331 259724 tempffc.updateSolid();
16332
16333
16334
4/6
✓ Branch 0 taken 259724 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 253720 times.
✓ Branch 3 taken 6004 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 253720 times.
259724 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16335 {
16336 tempffc.flags|=ffc_ignoreholdup;
16337 }
16338
16339
1/2
✓ Branch 0 taken 259724 times.
✗ Branch 1 not taken.
259724 if(version>9)
16340 {
16341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetw(&(tempffc.script),f))
16342 {
16343 return qe_invalid;
16344 }
16345 259724 }
16346 else
16347 {
16348 tempffc.script=0;
16349 }
16350
16351
1/2
✓ Branch 0 taken 259724 times.
✗ Branch 1 not taken.
259724 if(version>10)
16352 {
16353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetl(&(tempffc.initd[0]),f))
16354 {
16355 return qe_invalid;
16356 }
16357
16358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetl(&(tempffc.initd[1]),f))
16359 {
16360 return qe_invalid;
16361 }
16362
16363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetl(&(tempffc.initd[2]),f))
16364 {
16365 return qe_invalid;
16366 }
16367
16368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetl(&(tempffc.initd[3]),f))
16369 {
16370 return qe_invalid;
16371 }
16372
16373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetl(&(tempffc.initd[4]),f))
16374 {
16375 return qe_invalid;
16376 }
16377
16378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetl(&(tempffc.initd[5]),f))
16379 {
16380 return qe_invalid;
16381 }
16382
16383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetl(&(tempffc.initd[6]),f))
16384 {
16385 return qe_invalid;
16386 }
16387
16388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetl(&(tempffc.initd[7]),f))
16389 {
16390 return qe_invalid;
16391 }
16392
16393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_getc(&(tempbyte),f))
16394 {
16395 return qe_invalid;
16396 }
16397
16398 259724 tempffc.inita[0]=tempbyte*10000;
16399
16400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_getc(&(tempbyte),f))
16401 {
16402 return qe_invalid;
16403 }
16404
16405 259724 tempffc.inita[1]=tempbyte*10000;
16406 259724 }
16407 else
16408 {
16409 tempffc.inita[0] = 10000;
16410 tempffc.inita[1] = 10000;
16411 }
16412
16413
1/2
✓ Branch 0 taken 259724 times.
✗ Branch 1 not taken.
259724 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
16414 {
16415 tempffc.script = 0;
16416 for(int q = 0; q < 8; ++q)
16417 tempffc.initd[q] = 0;
16418 }
16419
1/2
✓ Branch 0 taken 259724 times.
✗ Branch 1 not taken.
259724 if(version <= 11)
16420 {
16421 fixffcs=true;
16422 }
16423 259724 }
16424 20045312 }
16425
2/2
✓ Branch 0 taken 60135936 times.
✓ Branch 1 taken 626416 times.
60762352 for(m = 32; m < MAXFFCS; ++m)
16426 {
16427 60135936 temp_mapscr->ffcs[m].clear();
16428 60135936 }
16429 626416 }
16430
16431 //add in the new whistle flags
16432
2/2
✓ Branch 0 taken 626416 times.
✓ Branch 1 taken 528504 times.
1154920 if(version<13)
16433 {
16434
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 528380 times.
528504 if(temp_mapscr->flags & fWHISTLE)
16435 {
16436 124 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16437 124 }
16438 528504 }
16439
16440 //2.55 starts here
16441
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1120512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1154920 if ( version >= 19 && Header->zelda_version > 0x253 )
16442 {
16443
2/2
✓ Branch 0 taken 344080 times.
✓ Branch 1 taken 34408 times.
378488 for ( int32_t q = 0; q < 10; q++ )
16444 {
16445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344080 times.
344080 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
16446 {
16447 return qe_invalid;
16448 }
16449 344080 }
16450
2/2
✓ Branch 0 taken 344080 times.
✓ Branch 1 taken 34408 times.
378488 for ( int32_t q = 0; q < 10; q++ )
16451 {
16452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344080 times.
344080 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
16453 {
16454 return qe_invalid;
16455 }
16456 344080 }
16457
2/2
✓ Branch 0 taken 344080 times.
✓ Branch 1 taken 34408 times.
378488 for ( int32_t q = 0; q < 10; q++ )
16458 {
16459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344080 times.
344080 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
16460 {
16461 return qe_invalid;
16462 }
16463 344080 }
16464
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 344080 times.
378488 for ( int32_t q = 0; q < 10; q++ )
16465 {
16466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344080 times.
344080 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
16467 {
16468 return qe_invalid;
16469 }
16470 344080 }
16471 34408 }
16472
3/4
✓ Branch 0 taken 1120512 times.
✓ Branch 1 taken 34408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1120512 times.
1154920 if ( version < 19 && Header->zelda_version > 0x253 )
16473 {
16474 for ( int32_t q = 0; q < 10; q++ )
16475 {
16476 temp_mapscr->npcstrings[q] = 0;
16477 temp_mapscr->new_items[q] = 0;
16478 temp_mapscr->new_item_x[q] = 0;
16479 temp_mapscr->new_item_y[q] = 0;
16480 }
16481 }
16482
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1120512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1154920 if ( version >= 20 && Header->zelda_version > 0x253 )
16483 {
16484
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_igetw(&(temp_mapscr->script),f))
16485 {
16486 return qe_invalid;
16487 }
16488
2/2
✓ Branch 0 taken 275264 times.
✓ Branch 1 taken 34408 times.
309672 for ( int32_t q = 0; q < 8; q++)
16489 {
16490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275264 times.
275264 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16491 {
16492 return qe_invalid;
16493 }
16494 275264 }
16495 34408 }
16496
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1120512 times.
1154920 if ( version < 20 )
16497 {
16498 1120512 temp_mapscr->script = 0;
16499
2/2
✓ Branch 0 taken 8964096 times.
✓ Branch 1 taken 1120512 times.
10084608 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16500 1120512 }
16501
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1120512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1154920 if ( version >= 21 && Header->zelda_version > 0x253 )
16502 {
16503
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->preloadscript),f))
16504 {
16505 return qe_invalid;
16506 }
16507 34408 }
16508
2/2
✓ Branch 0 taken 1120512 times.
✓ Branch 1 taken 34408 times.
1154920 if ( version < 21 )
16509 {
16510 1120512 temp_mapscr->preloadscript = 0;
16511 1120512 }
16512 //all builds with version > 20 need this. -Z
16513
16514
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1120512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1154920 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16515 {
16516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_getc(&(temp_mapscr->hidelayers ),f))
16517 {
16518 return qe_invalid;
16519 }
16520
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f))
16521 {
16522 return qe_invalid;
16523 }
16524 34408 }
16525
2/2
✓ Branch 0 taken 1120512 times.
✓ Branch 1 taken 34408 times.
1154920 if ( version < 22 )
16526 {
16527 1120512 temp_mapscr->hidelayers = 0;
16528 1120512 temp_mapscr->hidescriptlayers = 0;
16529 1120512 }
16530
16531 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16532 //May be any version before 2.11. -Z
16533 /* --not the roar, the HIT SFX
16534 if ( Header->zelda_version <= 0x210 )
16535 {
16536 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16537 {
16538 temp_mapscr->bosssfx = WAV_ROAR;
16539 }
16540 }
16541 */
16542
2/2
✓ Branch 0 taken 4619680 times.
✓ Branch 1 taken 1154920 times.
5774600 for(int32_t k=0; k<4; k++)
16543 {
16544
1/2
✓ Branch 0 taken 4619680 times.
✗ Branch 1 not taken.
4619680 if(temp_mapscr->door[k] == dNONE)
16545 temp_mapscr->door[k] = dWALL;
16546 4619680 }
16547
16548 1154920 return 0;
16549 1154920 }
16550 1331312 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
16551 {
16552
2/2
✓ Branch 0 taken 1154920 times.
✓ Branch 1 taken 176392 times.
1331312 if(version < 23)
16553 {
16554 1154920 auto ret = readmapscreen_old(f,Header,temp_mapscr,version);
16555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(ret) return ret;
16556 1154920 }
16557 else
16558 {
16559
1/2
✓ Branch 0 taken 176392 times.
✗ Branch 1 not taken.
176392 if(!p_getc(&(temp_mapscr->valid),f))
16560 return qe_invalid;
16561
2/2
✓ Branch 0 taken 131718 times.
✓ Branch 1 taken 44674 times.
176392 if(!(temp_mapscr->valid & mVALID))
16562 {
16563 131718 int map = scrind/MAPSCRS;
16564 131718 int scr = scrind%MAPSCRS;
16565
4/6
✓ Branch 0 taken 124356 times.
✓ Branch 1 taken 7362 times.
✓ Branch 2 taken 124356 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124356 times.
✗ Branch 5 not taken.
131718 if(version > 25 && scrind > -1 && (map*6+5) < map_autolayers.size())
16566 {
16567 //Empty screen, apply autolayers
16568
2/2
✓ Branch 0 taken 15156 times.
✓ Branch 1 taken 124356 times.
139512 for(int q = 0; q < 6; ++q)
16569 {
16570 15156 auto layermap = map_autolayers[map*6+q];
16571 15156 temp_mapscr->layermap[q] = layermap;
16572 15156 if(layermap)
16573 15156 temp_mapscr->layerscreen[q] = scr;
16574 15156 }
16575 124356 }
16576 131718 return 0;
16577 }
16578 uint32_t scr_has_flags;
16579
1/2
✓ Branch 0 taken 44674 times.
✗ Branch 1 not taken.
44674 if(!p_igetl(&scr_has_flags,f))
16580 return qe_invalid;
16581
16582
2/2
✓ Branch 0 taken 10470 times.
✓ Branch 1 taken 34204 times.
44674 if(scr_has_flags & SCRHAS_ROOMDATA)
16583 {
16584
1/2
✓ Branch 0 taken 34204 times.
✗ Branch 1 not taken.
34204 if(!p_getc(&(temp_mapscr->guy),f))
16585 return qe_invalid;
16586
2/2
✓ Branch 0 taken 34084 times.
✓ Branch 1 taken 120 times.
34204 if(version > 26)
16587 {
16588
1/2
✓ Branch 0 taken 34084 times.
✗ Branch 1 not taken.
34084 if(!p_igetl(&(temp_mapscr->guytile),f))
16589 return qe_invalid;
16590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34084 times.
34084 if(!p_getc(&(temp_mapscr->guycs),f))
16591 return qe_invalid;
16592
1/2
✓ Branch 0 taken 34084 times.
✗ Branch 1 not taken.
34084 if(!p_igetw(&(temp_mapscr->roomflags),f))
16593 return qe_invalid;
16594 34084 }
16595 else
16596 {
16597 120 temp_mapscr->guytile = -1; //signal to use default guy values
16598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
16599
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
120 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
16600 }
16601
1/2
✓ Branch 0 taken 34204 times.
✗ Branch 1 not taken.
34204 if(!p_igetw(&(temp_mapscr->str),f))
16602 return qe_invalid;
16603
1/2
✓ Branch 0 taken 34204 times.
✗ Branch 1 not taken.
34204 if(!p_getc(&(temp_mapscr->room),f))
16604 return qe_invalid;
16605
1/2
✓ Branch 0 taken 34204 times.
✗ Branch 1 not taken.
34204 if(!p_igetw(&(temp_mapscr->catchall),f))
16606 return qe_invalid;
16607 34204 }
16608
2/2
✓ Branch 0 taken 42878 times.
✓ Branch 1 taken 1796 times.
44674 if(scr_has_flags & SCRHAS_ITEM)
16609 {
16610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1796 times.
1796 if(!p_getc(&(temp_mapscr->item),f))
16611 return qe_invalid;
16612
1/2
✓ Branch 0 taken 1796 times.
✗ Branch 1 not taken.
1796 if(!p_getc(&(temp_mapscr->hasitem),f))
16613 return qe_invalid;
16614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1796 times.
1796 if(!p_getc(&(temp_mapscr->itemx),f))
16615 return qe_invalid;
16616
1/2
✓ Branch 0 taken 1796 times.
✗ Branch 1 not taken.
1796 if(!p_getc(&(temp_mapscr->itemy),f))
16617 return qe_invalid;
16618 1796 }
16619
2/2
✓ Branch 0 taken 36251 times.
✓ Branch 1 taken 8423 times.
44674 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
16620 {
16621
1/2
✓ Branch 0 taken 8423 times.
✗ Branch 1 not taken.
8423 if(!p_igetw(&temp_mapscr->warpreturnc,f))
16622 return qe_invalid;
16623 8423 }
16624
2/2
✓ Branch 0 taken 42581 times.
✓ Branch 1 taken 2093 times.
44674 if(scr_has_flags & SCRHAS_TWARP)
16625 {
16626
2/2
✓ Branch 0 taken 8372 times.
✓ Branch 1 taken 2093 times.
10465 for(int32_t i=0; i<4; i++)
16627 {
16628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8372 times.
8372 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
16629 return qe_invalid;
16630 8372 }
16631
2/2
✓ Branch 0 taken 8372 times.
✓ Branch 1 taken 2093 times.
10465 for(int32_t i=0; i<4; i++)
16632 {
16633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8372 times.
8372 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
16634 return qe_invalid;
16635 8372 }
16636
2/2
✓ Branch 0 taken 8372 times.
✓ Branch 1 taken 2093 times.
10465 for(int32_t i=0; i<4; i++)
16637 {
16638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8372 times.
8372 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
16639 return qe_invalid;
16640 8372 }
16641
1/2
✓ Branch 0 taken 2093 times.
✗ Branch 1 not taken.
2093 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
16642 return qe_invalid;
16643 2093 }
16644
2/2
✓ Branch 0 taken 37912 times.
✓ Branch 1 taken 6762 times.
44674 if(scr_has_flags & SCRHAS_SWARP)
16645 {
16646
2/2
✓ Branch 0 taken 27048 times.
✓ Branch 1 taken 6762 times.
33810 for(int32_t i=0; i<4; i++)
16647 {
16648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27048 times.
27048 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
16649 return qe_invalid;
16650 27048 }
16651
2/2
✓ Branch 0 taken 27048 times.
✓ Branch 1 taken 6762 times.
33810 for(int32_t i=0; i<4; i++)
16652 {
16653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27048 times.
27048 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
16654 return qe_invalid;
16655 27048 }
16656
2/2
✓ Branch 0 taken 27048 times.
✓ Branch 1 taken 6762 times.
33810 for(int32_t i=0; i<4; i++)
16657 {
16658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27048 times.
27048 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
16659 return qe_invalid;
16660 27048 }
16661
1/2
✓ Branch 0 taken 6762 times.
✗ Branch 1 not taken.
6762 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
16662 return qe_invalid;
16663
1/2
✓ Branch 0 taken 6762 times.
✗ Branch 1 not taken.
6762 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
16664 return qe_invalid;
16665 6762 }
16666
2/2
✓ Branch 0 taken 39899 times.
✓ Branch 1 taken 4775 times.
44674 if(scr_has_flags & SCRHAS_WARPRET)
16667 {
16668
2/2
✓ Branch 0 taken 19100 times.
✓ Branch 1 taken 4775 times.
23875 for(int32_t i=0; i<4; i++)
16669 {
16670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19100 times.
19100 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
16671 return qe_invalid;
16672 19100 }
16673
2/2
✓ Branch 0 taken 19100 times.
✓ Branch 1 taken 4775 times.
23875 for(int32_t i=0; i<4; i++)
16674 {
16675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19100 times.
19100 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
16676 return qe_invalid;
16677 19100 }
16678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4775 times.
4775 if(!p_getc(&(temp_mapscr->warparrivalx),f))
16679 return qe_invalid;
16680
1/2
✓ Branch 0 taken 4775 times.
✗ Branch 1 not taken.
4775 if(!p_getc(&(temp_mapscr->warparrivaly),f))
16681 return qe_invalid;
16682 4775 }
16683
2/2
✓ Branch 0 taken 34046 times.
✓ Branch 1 taken 10628 times.
44674 if(scr_has_flags & SCRHAS_LAYERS)
16684 {
16685
2/2
✓ Branch 0 taken 63768 times.
✓ Branch 1 taken 10628 times.
74396 for(int32_t k=0; k<6; k++)
16686 {
16687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63768 times.
63768 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16688 return qe_invalid;
16689 63768 }
16690
2/2
✓ Branch 0 taken 63768 times.
✓ Branch 1 taken 10628 times.
74396 for(int32_t k=0; k<6; k++)
16691 {
16692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63768 times.
63768 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16693 return qe_invalid;
16694 63768 }
16695
2/2
✓ Branch 0 taken 63768 times.
✓ Branch 1 taken 10628 times.
74396 for(int32_t k=0; k<6; k++)
16696 {
16697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63768 times.
63768 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16698 return qe_invalid;
16699 63768 }
16700
1/2
✓ Branch 0 taken 10628 times.
✗ Branch 1 not taken.
10628 if(!p_getc(&(temp_mapscr->hidelayers),f))
16701 return qe_invalid;
16702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10628 times.
10628 if(!p_getc(&(temp_mapscr->hidescriptlayers),f))
16703 return qe_invalid;
16704 10628 }
16705
2/2
✓ Branch 0 taken 44672 times.
✓ Branch 1 taken 2 times.
44674 if(scr_has_flags & SCRHAS_MAZE)
16706 {
16707
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t k=0; k<4; k++)
16708 {
16709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&(temp_mapscr->path[k]),f))
16710 return qe_invalid;
16711 8 }
16712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!p_getc(&(temp_mapscr->exitdir),f))
16713 return qe_invalid;
16714 2 }
16715
2/2
✓ Branch 0 taken 20079 times.
✓ Branch 1 taken 24595 times.
44674 if(scr_has_flags & SCRHAS_D_S_U)
16716 {
16717
1/2
✓ Branch 0 taken 20079 times.
✗ Branch 1 not taken.
20079 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
16718 return qe_invalid;
16719
2/2
✓ Branch 0 taken 80316 times.
✓ Branch 1 taken 20079 times.
100395 for(int32_t k=0; k<4; k++)
16720 {
16721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80316 times.
80316 if(!p_getc(&(temp_mapscr->door[k]),f))
16722 return qe_invalid;
16723
3/4
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 79940 times.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
80316 if(version < 29 && temp_mapscr->door[k] == dNONE)
16724 temp_mapscr->door[k] = dWALL;
16725 80316 }
16726
16727
1/2
✓ Branch 0 taken 20079 times.
✗ Branch 1 not taken.
20079 if(!p_getc(&(temp_mapscr->stairx),f))
16728 return qe_invalid;
16729
16730
1/2
✓ Branch 0 taken 20079 times.
✗ Branch 1 not taken.
20079 if(!p_getc(&(temp_mapscr->stairy),f))
16731 return qe_invalid;
16732
1/2
✓ Branch 0 taken 20079 times.
✗ Branch 1 not taken.
20079 if(!p_igetw(&(temp_mapscr->undercombo),f))
16733 return qe_invalid;
16734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20079 times.
20079 if(!p_getc(&(temp_mapscr->undercset),f))
16735 return qe_invalid;
16736 20079 }
16737
2/2
✓ Branch 0 taken 14099 times.
✓ Branch 1 taken 10496 times.
24595 else if(version < 29)
16738 {
16739
2/2
✓ Branch 0 taken 41984 times.
✓ Branch 1 taken 10496 times.
52480 for(int k = 0; k < 4; ++k)
16740 41984 temp_mapscr->door[k] = dWALL;
16741 10496 }
16742
2/2
✓ Branch 0 taken 38948 times.
✓ Branch 1 taken 5726 times.
44674 if(scr_has_flags & SCRHAS_FLAGS)
16743 {
16744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5726 times.
5726 if(!p_getc(&(temp_mapscr->flags),f))
16745 return qe_invalid;
16746
1/2
✓ Branch 0 taken 5726 times.
✗ Branch 1 not taken.
5726 if(!p_getc(&(temp_mapscr->flags2),f))
16747 return qe_invalid;
16748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5726 times.
5726 if(!p_getc(&(temp_mapscr->flags3),f))
16749 return qe_invalid;
16750
1/2
✓ Branch 0 taken 5726 times.
✗ Branch 1 not taken.
5726 if(!p_getc(&(temp_mapscr->flags4),f))
16751 return qe_invalid;
16752
1/2
✓ Branch 0 taken 5726 times.
✗ Branch 1 not taken.
5726 if(!p_getc(&(temp_mapscr->flags5),f))
16753 return qe_invalid;
16754
1/2
✓ Branch 0 taken 5726 times.
✗ Branch 1 not taken.
5726 if(!p_getc(&(temp_mapscr->flags6),f))
16755 return qe_invalid;
16756
1/2
✓ Branch 0 taken 5726 times.
✗ Branch 1 not taken.
5726 if(!p_getc(&(temp_mapscr->flags7),f))
16757 return qe_invalid;
16758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5726 times.
5726 if(!p_getc(&(temp_mapscr->flags8),f))
16759 return qe_invalid;
16760
1/2
✓ Branch 0 taken 5726 times.
✗ Branch 1 not taken.
5726 if(!p_getc(&(temp_mapscr->flags9),f))
16761 return qe_invalid;
16762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5726 times.
5726 if(!p_getc(&(temp_mapscr->flags10),f))
16763 return qe_invalid;
16764
1/2
✓ Branch 0 taken 5726 times.
✗ Branch 1 not taken.
5726 if(!p_getc(&(temp_mapscr->enemyflags),f))
16765 return qe_invalid;
16766 5726 }
16767
2/2
✓ Branch 0 taken 40160 times.
✓ Branch 1 taken 4514 times.
44674 if(scr_has_flags & SCRHAS_ENEMY)
16768 {
16769
2/2
✓ Branch 0 taken 45140 times.
✓ Branch 1 taken 4514 times.
49654 for(int32_t k=0; k<10; k++)
16770 {
16771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45140 times.
45140 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
16772 return qe_invalid;
16773
1/2
✓ Branch 0 taken 45140 times.
✗ Branch 1 not taken.
45140 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
16774 temp_mapscr->enemy[k] = 0;
16775 45140 }
16776
1/2
✓ Branch 0 taken 4514 times.
✗ Branch 1 not taken.
4514 if(!p_getc(&(temp_mapscr->pattern),f))
16777 return qe_invalid;
16778 4514 }
16779
2/2
✓ Branch 0 taken 44356 times.
✓ Branch 1 taken 318 times.
44674 if(scr_has_flags & SCRHAS_CARRY)
16780 {
16781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 318 times.
318 if(!p_igetw(&(temp_mapscr->noreset),f))
16782 return qe_invalid;
16783
1/2
✓ Branch 0 taken 318 times.
✗ Branch 1 not taken.
318 if(!p_igetw(&(temp_mapscr->nocarry),f))
16784 return qe_invalid;
16785
1/2
✓ Branch 0 taken 318 times.
✗ Branch 1 not taken.
318 if(!p_getc(&(temp_mapscr->nextmap),f))
16786 return qe_invalid;
16787
1/2
✓ Branch 0 taken 318 times.
✗ Branch 1 not taken.
318 if(!p_getc(&(temp_mapscr->nextscr),f))
16788 return qe_invalid;
16789 318 }
16790
2/2
✓ Branch 0 taken 44211 times.
✓ Branch 1 taken 463 times.
44674 if(scr_has_flags & SCRHAS_SCRIPT)
16791 {
16792
1/2
✓ Branch 0 taken 463 times.
✗ Branch 1 not taken.
463 if(!p_igetw(&(temp_mapscr->script),f))
16793 return qe_invalid;
16794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 463 times.
463 if(!p_getc(&(temp_mapscr->preloadscript),f))
16795 return qe_invalid;
16796
2/2
✓ Branch 0 taken 3704 times.
✓ Branch 1 taken 463 times.
4167 for ( int32_t q = 0; q < 8; q++ )
16797 {
16798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3704 times.
3704 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16799 return qe_invalid;
16800 3704 }
16801 463 }
16802
1/2
✓ Branch 0 taken 44674 times.
✗ Branch 1 not taken.
44674 if(scr_has_flags & SCRHAS_UNUSED)
16803 {
16804 for ( int32_t q = 0; q < 10; q++ )
16805 {
16806 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
16807 return qe_invalid;
16808 }
16809 for ( int32_t q = 0; q < 10; q++ )
16810 {
16811 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
16812 return qe_invalid;
16813 }
16814 for ( int32_t q = 0; q < 10; q++ )
16815 {
16816 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
16817 return qe_invalid;
16818 }
16819 for ( int32_t q = 0; q < 10; q++ )
16820 {
16821 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
16822 return qe_invalid;
16823 }
16824 }
16825
2/2
✓ Branch 0 taken 39618 times.
✓ Branch 1 taken 5056 times.
44674 if(scr_has_flags & SCRHAS_SECRETS)
16826 {
16827
2/2
✓ Branch 0 taken 647168 times.
✓ Branch 1 taken 5056 times.
652224 for(int32_t k=0; k<128; k++)
16828 {
16829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 647168 times.
647168 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16830 return qe_invalid;
16831 647168 }
16832
2/2
✓ Branch 0 taken 647168 times.
✓ Branch 1 taken 5056 times.
652224 for(int32_t k=0; k<128; k++)
16833 {
16834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 647168 times.
647168 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16835 return qe_invalid;
16836 647168 }
16837
2/2
✓ Branch 0 taken 647168 times.
✓ Branch 1 taken 5056 times.
652224 for(int32_t k=0; k<128; k++)
16838 {
16839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 647168 times.
647168 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16840 return qe_invalid;
16841 647168 }
16842 5056 }
16843
2/2
✓ Branch 0 taken 13165 times.
✓ Branch 1 taken 31509 times.
44674 if(scr_has_flags & SCRHAS_COMBOFLAG)
16844 {
16845
2/2
✓ Branch 0 taken 5545584 times.
✓ Branch 1 taken 31509 times.
5577093 for(int32_t k=0; k<176; ++k)
16846 {
16847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5545584 times.
5545584 if(!p_igetw(&(temp_mapscr->data[k]),f))
16848 return qe_invalid;
16849 5545584 }
16850
2/2
✓ Branch 0 taken 5545584 times.
✓ Branch 1 taken 31509 times.
5577093 for(int32_t k=0; k<176; ++k)
16851 {
16852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5545584 times.
5545584 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16853 return qe_invalid;
16854 5545584 }
16855
2/2
✓ Branch 0 taken 5545584 times.
✓ Branch 1 taken 31509 times.
5577093 for(int32_t k=0; k<176; ++k)
16856 {
16857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5545584 times.
5545584 if(!p_getc(&(temp_mapscr->cset[k]),f))
16858 return qe_invalid;
16859 5545584 }
16860 31509 }
16861
1/2
✓ Branch 0 taken 44674 times.
✗ Branch 1 not taken.
44674 if(scr_has_flags & SCRHAS_MISC)
16862 {
16863
1/2
✓ Branch 0 taken 44674 times.
✗ Branch 1 not taken.
44674 if(!p_igetw(&(temp_mapscr->color),f))
16864 return qe_invalid;
16865
1/2
✓ Branch 0 taken 44674 times.
✗ Branch 1 not taken.
44674 if(!p_getc(&(temp_mapscr->csensitive),f))
16866 return qe_invalid;
16867
1/2
✓ Branch 0 taken 44674 times.
✗ Branch 1 not taken.
44674 if(!p_getc(&(temp_mapscr->oceansfx),f))
16868 return qe_invalid;
16869
1/2
✓ Branch 0 taken 44674 times.
✗ Branch 1 not taken.
44674 if(!p_getc(&(temp_mapscr->bosssfx),f))
16870 return qe_invalid;
16871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44674 times.
44674 if(!p_getc(&(temp_mapscr->secretsfx),f))
16872 return qe_invalid;
16873
1/2
✓ Branch 0 taken 44674 times.
✗ Branch 1 not taken.
44674 if(!p_getc(&(temp_mapscr->holdupsfx),f))
16874 return qe_invalid;
16875
1/2
✓ Branch 0 taken 44674 times.
✗ Branch 1 not taken.
44674 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16876 return qe_invalid;
16877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44674 times.
44674 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16878 return qe_invalid;
16879
1/2
✓ Branch 0 taken 44674 times.
✗ Branch 1 not taken.
44674 if(!p_getc(&(temp_mapscr->lens_layer),f))
16880 return qe_invalid;
16881
2/2
✓ Branch 0 taken 10590 times.
✓ Branch 1 taken 34084 times.
44674 if(version > 27)
16882 {
16883
1/2
✓ Branch 0 taken 34084 times.
✗ Branch 1 not taken.
34084 if(!p_getc(&(temp_mapscr->lens_show),f))
16884 return qe_invalid;
16885
1/2
✓ Branch 0 taken 34084 times.
✗ Branch 1 not taken.
34084 if(!p_getc(&(temp_mapscr->lens_hide),f))
16886 return qe_invalid;
16887 34084 }
16888 44674 }
16889 else
16890 {
16891 temp_mapscr->screen_midi = -1;
16892 temp_mapscr->csensitive = 1;
16893 }
16894 //FFC
16895 44674 bool old_ff = version < 25;
16896 44674 dword bits = 0;
16897 44674 word numffc = 32;
16898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44674 times.
44674 if(old_ff)
16899 {
16900 if(!p_igetl(&bits,f))
16901 return qe_invalid;
16902 }
16903 else
16904 {
16905
1/2
✓ Branch 0 taken 44674 times.
✗ Branch 1 not taken.
44674 if(!p_igetw(&numffc,f))
16906 return qe_invalid;
16907 }
16908 byte tempbyte;
16909 word tempw;
16910
4/6
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 44399 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 275 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 275 times.
44674 static ffcdata nil_ffc;
16911 44674 temp_mapscr->ffcCountMarkDirty();
16912
2/2
✓ Branch 0 taken 77514 times.
✓ Branch 1 taken 44674 times.
122188 for(word m = 0; m < numffc; ++m)
16913 {
16914
1/2
✓ Branch 0 taken 77514 times.
✗ Branch 1 not taken.
77514 ffcdata& tempffc = (m < MAXFFCS)
16915 77514 ? temp_mapscr->ffcs[m]
16916 : nil_ffc; //sanity
16917 77514 tempffc.clear();
16918
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 77514 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
77514 if(old_ff && !(bits & (1<<m))) continue;
16919
16920
1/2
✓ Branch 0 taken 77514 times.
✗ Branch 1 not taken.
77514 if(!p_igetw(&tempw,f))
16921 return qe_invalid;
16922
3/4
✓ Branch 0 taken 77514 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12575 times.
✓ Branch 3 taken 64939 times.
77514 if(!old_ff && !tempw) //empty ffc, nothing more to load
16923 64939 continue;
16924 12575 tempffc.data = tempw;
16925
16926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12575 times.
12575 if(!p_getc(&(tempffc.cset),f))
16927 return qe_invalid;
16928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12575 times.
12575 if(!p_igetw(&(tempffc.delay),f))
16929 return qe_invalid;
16930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12575 times.
12575 if(!p_igetzf(&(tempffc.x),f))
16931 return qe_invalid;
16932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12575 times.
12575 if(!p_igetzf(&(tempffc.y),f))
16933 return qe_invalid;
16934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12575 times.
12575 if(!p_igetzf(&(tempffc.vx),f))
16935 return qe_invalid;
16936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12575 times.
12575 if(!p_igetzf(&(tempffc.vy),f))
16937 return qe_invalid;
16938
1/2
✓ Branch 0 taken 12575 times.
✗ Branch 1 not taken.
12575 if(!p_igetzf(&(tempffc.ax),f))
16939 return qe_invalid;
16940
1/2
✓ Branch 0 taken 12575 times.
✗ Branch 1 not taken.
12575 if(!p_igetzf(&(tempffc.ay),f))
16941 return qe_invalid;
16942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12575 times.
12575 if(!p_getc(&(tempffc.link),f))
16943 return qe_invalid;
16944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12575 times.
12575 if(version < 24)
16945 {
16946 if(!p_getc(&tempbyte,f))
16947 return qe_invalid;
16948 tempffc.hit_width = (tempbyte&0x3F)+1;
16949 tempffc.txsz = (tempbyte>>6)+1;
16950 if(!p_getc(&tempbyte,f))
16951 return qe_invalid;
16952 tempffc.hit_height = (tempbyte&0x3F)+1;
16953 tempffc.tysz = (tempbyte>>6)+1;
16954 }
16955 else
16956 {
16957
1/2
✓ Branch 0 taken 12575 times.
✗ Branch 1 not taken.
12575 if(!p_igetl(&(tempffc.hit_width),f))
16958 return qe_invalid;
16959
1/2
✓ Branch 0 taken 12575 times.
✗ Branch 1 not taken.
12575 if(!p_igetl(&(tempffc.hit_height),f))
16960 return qe_invalid;
16961
1/2
✓ Branch 0 taken 12575 times.
✗ Branch 1 not taken.
12575 if(!p_getc(&(tempffc.txsz),f))
16962 return qe_invalid;
16963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12575 times.
12575 if(!p_getc(&(tempffc.tysz),f))
16964 return qe_invalid;
16965 }
16966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12575 times.
12575 if(!p_igetl(&(tempffc.flags),f))
16967 return qe_invalid;
16968 12575 tempffc.updateSolid();
16969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12575 times.
12575 if(!p_igetw(&(tempffc.script),f))
16970 return qe_invalid;
16971
2/2
✓ Branch 0 taken 100600 times.
✓ Branch 1 taken 12575 times.
113175 for(auto q = 0; q < 8; ++q)
16972 {
16973
1/2
✓ Branch 0 taken 100600 times.
✗ Branch 1 not taken.
100600 if(!p_igetl(&(tempffc.initd[q]),f))
16974 return qe_invalid;
16975 100600 }
16976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12575 times.
12575 if(!p_getc(&(tempbyte),f))
16977 return qe_invalid;
16978 12575 tempffc.inita[0]=tempbyte*10000;
16979
16980
1/2
✓ Branch 0 taken 12575 times.
✗ Branch 1 not taken.
12575 if(!p_getc(&(tempbyte),f))
16981 return qe_invalid;
16982 12575 tempffc.inita[1]=tempbyte*10000;
16983
16984
1/2
✓ Branch 0 taken 12575 times.
✗ Branch 1 not taken.
12575 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
16985 {
16986 tempffc.script = 0;
16987 for(int q = 0; q < 8; ++q)
16988 tempffc.initd[q] = 0;
16989 }
16990 12575 }
16991
2/2
✓ Branch 0 taken 5640758 times.
✓ Branch 1 taken 44674 times.
5685432 for(word m = numffc; m < MAXFFCS; ++m)
16992 {
16993 5640758 temp_mapscr->ffcs[m].clear();
16994 5640758 }
16995 //END FFC
16996
2/2
✓ Branch 0 taken 35846 times.
✓ Branch 1 taken 8828 times.
44674 if(version > 29)
16997
1/2
✓ Branch 0 taken 8828 times.
✗ Branch 1 not taken.
8828 if(!p_getlstr(&temp_mapscr->usr_notes, f))
16998 return qe_invalid;
16999 }
17000 1199594 return 0;
17001 1331312 }
17002
17003
17004 693 int32_t readmaps(PACKFILE *f, zquestheader *Header)
17005 {
17006
2/2
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 24 times.
693 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
17007 693 int32_t scr=0;
17008
17009 693 word version=0;
17010 dword dummy;
17011 int32_t screens_to_read;
17012
17013 693 mapscr temp_mapscr;
17014 word temp_map_count;
17015 dword section_size;
17016
17017
5/6
✓ Branch 0 taken 675 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 669 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
693 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17018 {
17019 18 screens_to_read=MAPSCRS192b136;
17020 18 }
17021 else
17022 {
17023 675 screens_to_read=MAPSCRS;
17024 }
17025
17026
2/2
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 24 times.
693 if(Header->zelda_version > 0x192)
17027 {
17028 //section version info
17029
2/4
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 669 times.
✗ Branch 3 not taken.
669 if(!p_igetw(&version,f))
17030 {
17031 return qe_invalid;
17032 }
17033
17034 669 FFCore.quest_format[vMaps] = version;
17035
17036
2/4
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 669 times.
✗ Branch 3 not taken.
669 if(!p_igetw(&dummy,f))
17037 {
17038 return qe_invalid;
17039 }
17040
17041 //section size
17042
2/4
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 669 times.
✗ Branch 3 not taken.
669 if(!p_igetl(&section_size,f))
17043 {
17044 return qe_invalid;
17045 }
17046
17047 //finally... section data
17048
2/4
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 669 times.
✗ Branch 3 not taken.
669 if(!p_igetw(&temp_map_count,f))
17049 {
17050 return 5;
17051 }
17052 669 }
17053 else
17054 {
17055 24 temp_map_count=map_count;
17056 }
17057
17058
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if (temp_map_count > MAXMAPS)
17059 {
17060 return qe_invalid;
17061 }
17062
17063
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 1 times.
693 if (!should_skip)
17064 {
17065 692 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17066
1/2
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
692 TheMaps.resize(_mapsSize);
17067 692 map_autolayers.clear();
17068
1/2
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
692 map_autolayers.resize(temp_map_count*6);
17069
2/2
✓ Branch 0 taken 1335928 times.
✓ Branch 1 taken 692 times.
1336620 for(int32_t i(0); i<_mapsSize; i++)
17070
1/2
✓ Branch 0 taken 1335928 times.
✗ Branch 1 not taken.
1335928 TheMaps[i].zero_memory();
17071 692 }
17072
17073
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 temp_mapscr.zero_memory();
17074
17075
4/4
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 9825 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 9825 times.
10518 for(int32_t i=0; i<temp_map_count && i<MAXMAPS; i++)
17076 {
17077 9825 byte valid=1;
17078
2/2
✓ Branch 0 taken 1328 times.
✓ Branch 1 taken 8497 times.
9825 if(version > 22)
17079 {
17080
2/4
✓ Branch 0 taken 1328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1328 times.
✗ Branch 3 not taken.
1328 if(!p_getc(&valid,f))
17081 return qe_invalid;
17082 1328 }
17083
4/4
✓ Branch 0 taken 9794 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 8629 times.
✓ Branch 3 taken 1165 times.
9825 if(valid && version > 25)
17084 {
17085
2/2
✓ Branch 0 taken 6990 times.
✓ Branch 1 taken 1165 times.
8155 for(int q = 0; q < 6; ++q)
17086 {
17087
2/4
✓ Branch 0 taken 6990 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6990 times.
✗ Branch 3 not taken.
6990 if(!p_igetw(&map_autolayers[i*6+q],f))
17088 return qe_invalid;
17089 6990 }
17090 1165 }
17091
2/2
✓ Branch 0 taken 1335528 times.
✓ Branch 1 taken 9825 times.
1345353 for(int32_t j=0; j<screens_to_read; j++)
17092 {
17093 1335528 scr=i*MAPSCRS+j;
17094
1/2
✓ Branch 0 taken 1335528 times.
✗ Branch 1 not taken.
1335528 clear_screen(&temp_mapscr);
17095
2/2
✓ Branch 0 taken 1331312 times.
✓ Branch 1 taken 4216 times.
1335528 if(valid)
17096
1/2
✓ Branch 0 taken 1331312 times.
✗ Branch 1 not taken.
1331312 readmapscreen(f, Header, &temp_mapscr, version, scr);
17097
17098
2/2
✓ Branch 0 taken 1335256 times.
✓ Branch 1 taken 272 times.
1335528 if (!should_skip)
17099
1/2
✓ Branch 0 taken 1335256 times.
✗ Branch 1 not taken.
1335256 TheMaps[scr] = temp_mapscr;
17100 1335528 }
17101
17102
2/2
✓ Branch 0 taken 9823 times.
✓ Branch 1 taken 2 times.
9825 if (should_skip)
17103 2 continue;
17104
17105
5/6
✓ Branch 0 taken 9655 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 9637 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
9823 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17106 {
17107 168 int32_t index = (i*MAPSCRS+132);
17108
17109
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 TheMaps[index]=TheMaps[index-1];
17110
17111 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17112 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17113 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17114
17115
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 168 times.
672 for(int32_t j=133; j<MAPSCRS; j++)
17116 {
17117 504 scr=i*MAPSCRS+j;
17118
17119
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 TheMaps[scr].zero_memory();
17120 504 TheMaps[scr].valid = mVERSION;
17121 504 TheMaps[scr].screen_midi = -1;
17122 504 TheMaps[scr].csensitive = 1;
17123 504 }
17124 168 }
17125
17126
5/6
✓ Branch 0 taken 9655 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 9637 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
9823 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17127 {
17128
2/2
✓ Branch 0 taken 22848 times.
✓ Branch 1 taken 168 times.
23016 for(int32_t j=0; j<MAPSCRS; j++)
17129 {
17130 22848 scr=i*MAPSCRS+j;
17131 22848 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17132
17133
2/2
✓ Branch 0 taken 2924544 times.
✓ Branch 1 taken 22848 times.
2947392 for(int32_t k=0; k<128; k++)
17134 {
17135
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17136
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17137
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17138 2924544 }
17139 22848 }
17140 168 }
17141 9823 }
17142 693 map_count = temp_map_count;
17143
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 clear_screen(&temp_mapscr);
17144 693 return 0;
17145 693 }
17146
17147
17148 9841768 void update_combo(newcombo& cmb, word section_version)
17149 {
17150
2/2
✓ Branch 0 taken 2267037 times.
✓ Branch 1 taken 7574731 times.
9841768 if(section_version < 40)
17151 {
17152
3/3
✓ Branch 0 taken 5025 times.
✓ Branch 1 taken 44980 times.
✓ Branch 2 taken 7524726 times.
7574731 switch(cmb.type)
17153 {
17154 case cWATER: case cSHALLOWWATER:
17155 44980 cmb.attribytes[6] = iwRipples;
17156 44980 break;
17157 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17158 5025 cmb.attribytes[6] = iwTallGrass;
17159 5025 break;
17160 }
17161 7574731 }
17162 9841768 }
17163 277 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos)
17164 {
17165
2/2
✓ Branch 0 taken 253 times.
✓ Branch 1 taken 24 times.
277 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
17166
17167
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 276 times.
277 if (!should_skip)
17168 {
17169 276 reset_combo_animations();
17170 276 reset_combo_animations2();
17171 276 init_combo_classes();
17172 276 }
17173
17174 // combos
17175 277 word combos_used=0;
17176 int32_t dummy;
17177 byte padding;
17178 277 newcombo temp_combo;
17179 //word section_cversion=0;
17180
17181
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 276 times.
277 if (!should_skip)
17182
2/2
✓ Branch 0 taken 18017280 times.
✓ Branch 1 taken 276 times.
18017556 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17183
1/2
✓ Branch 0 taken 18017280 times.
✗ Branch 1 not taken.
18017556 combobuf[q].clear();
17184
17185 // if(version > 0x192)
17186 // {
17187 // //section version info
17188 // if(!p_igetw(&section_version,f))
17189 // {
17190 // return qe_invalid;
17191 // }
17192
17193 // FFCore.quest_format[vCombos] = section_version;
17194
17195 // if(!p_igetw(&section_cversion,f))
17196 // {
17197 // return qe_invalid;
17198 // }
17199
17200 // //section size
17201 // if(!p_igetl(&dummy,f))
17202 // {
17203 // return qe_invalid;
17204 // }
17205 // }
17206
17207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 277 times.
277 if(version < 0x174)
17208 {
17209 combos_used=1024;
17210 }
17211
2/2
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 18 times.
277 else if(version < 0x191)
17212 {
17213 18 combos_used=2048;
17214 18 }
17215 else
17216 {
17217
2/4
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 259 times.
✗ Branch 3 not taken.
259 if(!p_igetw(&combos_used,f))
17218 {
17219 return qe_invalid;
17220 }
17221 }
17222
17223 //finally... section data
17224
2/2
✓ Branch 0 taken 7439715 times.
✓ Branch 1 taken 277 times.
7439992 for(int32_t i=0; i<combos_used; i++)
17225 {
17226
1/2
✓ Branch 0 taken 7439715 times.
✗ Branch 1 not taken.
7439715 temp_combo.clear();
17227
17228
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7236747 times.
7439715 if ( section_version >= 11 )
17229 {
17230
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.tile,f))
17231 {
17232 return qe_invalid;
17233 }
17234 202968 }
17235 else
17236 {
17237
2/4
✓ Branch 0 taken 7236747 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7236747 times.
✗ Branch 3 not taken.
7236747 if(!p_igetw(&temp_combo.tile,f))
17238 {
17239 return qe_invalid;
17240 }
17241 }
17242 7439715 temp_combo.o_tile = temp_combo.tile;
17243
2/4
✓ Branch 0 taken 7439715 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7439715 times.
✗ Branch 3 not taken.
7439715 if(!p_getc(&temp_combo.flip,f))
17244 {
17245 return qe_invalid;
17246 }
17247
17248
2/4
✓ Branch 0 taken 7439715 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7439715 times.
✗ Branch 3 not taken.
7439715 if(!p_getc(&temp_combo.walk,f))
17249 {
17250 return qe_invalid;
17251 }
17252
17253
2/4
✓ Branch 0 taken 7439715 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7439715 times.
✗ Branch 3 not taken.
7439715 if(!p_getc(&temp_combo.type,f))
17254 {
17255 return qe_invalid;
17256 }
17257
17258
2/4
✓ Branch 0 taken 7439715 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7439715 times.
✗ Branch 3 not taken.
7439715 if(!p_getc(&temp_combo.csets,f))
17259 {
17260 return qe_invalid;
17261 }
17262
17263
2/2
✓ Branch 0 taken 69774 times.
✓ Branch 1 taken 7369941 times.
7439715 if(version < 0x193)
17264 {
17265
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17266 return qe_invalid;
17267
17268
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17269 return qe_invalid;
17270
17271
2/2
✓ Branch 0 taken 32910 times.
✓ Branch 1 taken 36864 times.
69774 if(version < 0x192)
17272 {
17273
1/2
✓ Branch 0 taken 36864 times.
✗ Branch 1 not taken.
36864 if(version == 0x191)
17274 {
17275 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17276 {
17277 if(!p_getc(&padding,f))
17278 return qe_invalid;
17279 }
17280 }
17281 36864 }
17282 69774 }
17283
2/2
✓ Branch 0 taken 7402851 times.
✓ Branch 1 taken 36864 times.
7439715 if(version >= 0x192)
17284 {
17285
2/4
✓ Branch 0 taken 7402851 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7402851 times.
✗ Branch 3 not taken.
7402851 if(!p_getc(&temp_combo.frames,f))
17286 return qe_invalid;
17287
17288
2/4
✓ Branch 0 taken 7402851 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7402851 times.
✗ Branch 3 not taken.
7402851 if(!p_getc(&temp_combo.speed,f))
17289 return qe_invalid;
17290
17291
2/4
✓ Branch 0 taken 7402851 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7402851 times.
✗ Branch 3 not taken.
7402851 if(!p_igetw(&temp_combo.nextcombo,f))
17292 return qe_invalid;
17293
17294
2/4
✓ Branch 0 taken 7402851 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7402851 times.
✗ Branch 3 not taken.
7402851 if(!p_getc(&temp_combo.nextcset,f))
17295 return qe_invalid;
17296
17297 //Base flag
17298
2/2
✓ Branch 0 taken 4514443 times.
✓ Branch 1 taken 2888408 times.
7402851 if(section_version>=3)
17299
2/4
✓ Branch 0 taken 4514443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4514443 times.
✗ Branch 3 not taken.
4514443 if(!p_getc(&temp_combo.flag,f))
17300 return qe_invalid;
17301
17302
2/2
✓ Branch 0 taken 4514443 times.
✓ Branch 1 taken 2888408 times.
7402851 if(section_version>=4)
17303 {
17304
2/4
✓ Branch 0 taken 4514443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4514443 times.
✗ Branch 3 not taken.
4514443 if(!p_getc(&temp_combo.skipanim,f))
17305 return qe_invalid;
17306
17307
2/4
✓ Branch 0 taken 4514443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4514443 times.
✗ Branch 3 not taken.
4514443 if(!p_igetw(&temp_combo.nexttimer,f))
17308 return qe_invalid;
17309 4514443 }
17310
17311
2/2
✓ Branch 0 taken 4514443 times.
✓ Branch 1 taken 2888408 times.
7402851 if(section_version>=5)
17312
2/4
✓ Branch 0 taken 4514443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4514443 times.
✗ Branch 3 not taken.
4514443 if(!p_getc(&temp_combo.skipanimy,f))
17313 return qe_invalid;
17314
17315
2/2
✓ Branch 0 taken 4514443 times.
✓ Branch 1 taken 2888408 times.
7402851 if(section_version>=6)
17316 {
17317
2/4
✓ Branch 0 taken 4514443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4514443 times.
✗ Branch 3 not taken.
4514443 if(!p_getc(&temp_combo.animflags,f))
17318 return qe_invalid;
17319
17320
1/2
✓ Branch 0 taken 4514443 times.
✗ Branch 1 not taken.
4514443 if(section_version == 6)
17321 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17322 4514443 }
17323
17324
2/2
✓ Branch 0 taken 7199883 times.
✓ Branch 1 taken 202968 times.
7402851 if(section_version>=8) //combo Attributes[4] and userflags.
17325 {
17326
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 811872 times.
1014840 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17327
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_igetl(&temp_combo.attributes[q],f))
17328 return qe_invalid;
17329
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.usrflags,f))
17330 return qe_invalid;
17331
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 if(section_version >= 20)
17332
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.genflags,f))
17333 return qe_invalid;
17334 202968 }
17335
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7199883 times.
7402851 if(section_version>=10) //combo trigger flags
17336 {
17337
2/2
✓ Branch 0 taken 608904 times.
✓ Branch 1 taken 202968 times.
811872 for ( int32_t q = 0; q < 3; q++ )
17338
2/4
✓ Branch 0 taken 608904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 608904 times.
✗ Branch 3 not taken.
608904 if(!p_igetl(&temp_combo.triggerflags[q],f))
17339 return qe_invalid;
17340 202968 }
17341
1/2
✓ Branch 0 taken 7199883 times.
✗ Branch 1 not taken.
7199883 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17342 {
17343 for ( int32_t q = 0; q < 2; q++ )
17344 if(!p_igetl(&temp_combo.triggerflags[q],f))
17345 return qe_invalid;
17346 }
17347
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7199883 times.
7402851 if(section_version >= 9)
17348
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.triggerlevel,f))
17349 return qe_invalid;
17350
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7199883 times.
7402851 if(section_version >= 22)
17351
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.triggerbtn,f))
17352 return qe_invalid;
17353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7402851 times.
7402851 if(section_version >= 24)
17354 {
17355 if(!p_getc(&temp_combo.triggeritem,f))
17356 return qe_invalid;
17357 if(!p_getc(&temp_combo.trigtimer,f))
17358 return qe_invalid;
17359 }
17360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7402851 times.
7402851 if(section_version >= 25)
17361 if(!p_getc(&temp_combo.trigsfx,f))
17362 return qe_invalid;
17363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7402851 times.
7402851 if(section_version >= 27)
17364 if(!p_igetl(&temp_combo.trigchange,f))
17365 return qe_invalid;
17366
17367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7402851 times.
7402851 if(section_version >= 29)
17368 {
17369 if(!p_igetw(&temp_combo.trigprox,f))
17370 return qe_invalid;
17371 if(!p_getc(&temp_combo.trigctr,f))
17372 return qe_invalid;
17373 if(!p_igetl(&temp_combo.trigctramnt,f))
17374 return qe_invalid;
17375 }
17376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7402851 times.
7402851 if(section_version >= 30)
17377 if(!p_getc(&temp_combo.triglbeam,f))
17378 return qe_invalid;
17379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7402851 times.
7402851 if(section_version >= 31)
17380 {
17381 if(!p_getc(&temp_combo.trigcschange,f))
17382 return qe_invalid;
17383 if(!p_igetw(&temp_combo.spawnitem,f))
17384 return qe_invalid;
17385 if(!p_igetw(&temp_combo.spawnenemy,f))
17386 return qe_invalid;
17387 if(!p_getc(&temp_combo.exstate,f))
17388 return qe_invalid;
17389 if(!p_igetl(&temp_combo.spawnip,f))
17390 return qe_invalid;
17391 if(!p_getc(&temp_combo.trigcopycat,f))
17392 return qe_invalid;
17393 }
17394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7402851 times.
7402851 if(section_version >= 32)
17395 if(!p_getc(&temp_combo.trigcooldown,f))
17396 return qe_invalid;
17397
17398
2/2
✓ Branch 0 taken 7199883 times.
✓ Branch 1 taken 202968 times.
7402851 if(section_version>=12) //combo label
17399 {
17400 char label[12];
17401 202968 label[11] = '\0';
17402
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 2232648 times.
2435616 for ( int32_t q = 0; q < 11; q++ )
17403
2/4
✓ Branch 0 taken 2232648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2232648 times.
✗ Branch 3 not taken.
2232648 if(!p_getc(&label[q],f))
17404 return qe_invalid;
17405
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 temp_combo.label = label;
17406 202968 }
17407
2/2
✓ Branch 0 taken 7199883 times.
✓ Branch 1 taken 202968 times.
7402851 if(section_version>=13) //attribytes[4]
17408
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 0; q < 4; q++ )
17409
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17410 202968 return qe_invalid;
17411 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17412 * This fixes a poor implementation of a ->next flag bug thing.
17413 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17414 * there was a version bump a few weeks before a change that broke stuff.
17415 */
17416
3/4
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7199883 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 202968 times.
7402851 if (section_version >= 13 && section_version < 21)
17417 {
17418 set_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17419 }
17420 //combo scripts
17421
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7199883 times.
7402851 if(section_version>=14)
17422 {
17423
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.script,f))
17424 return qe_invalid;
17425
2/2
✓ Branch 0 taken 405936 times.
✓ Branch 1 taken 202968 times.
608904 for ( int32_t q = 0; q < 2; q++ )
17426
2/4
✓ Branch 0 taken 405936 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405936 times.
✗ Branch 3 not taken.
405936 if(!p_igetl(&temp_combo.initd[q],f))
17427 return qe_invalid;
17428 202968 }
17429
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7199883 times.
7402851 if(section_version>=15)
17430 {
17431
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.o_tile,f)) return qe_invalid;
17432
2/2
✓ Branch 0 taken 107633 times.
✓ Branch 1 taken 95335 times.
202968 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17433
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.cur_frame,f)) return qe_invalid;
17434
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.aclk,f)) return qe_invalid;
17435 202968 }
17436
2/2
✓ Branch 0 taken 7199883 times.
✓ Branch 1 taken 202968 times.
7402851 if(section_version>=17) //attribytes[4]
17437 {
17438
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17439
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17440 return qe_invalid;
17441
2/2
✓ Branch 0 taken 1623744 times.
✓ Branch 1 taken 202968 times.
1826712 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17442
2/4
✓ Branch 0 taken 1623744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1623744 times.
✗ Branch 3 not taken.
1623744 if(!p_igetw(&temp_combo.attrishorts[q],f))
17443 return qe_invalid;
17444 202968 }
17445
17446
2/2
✓ Branch 0 taken 7369941 times.
✓ Branch 1 taken 32910 times.
7402851 if(version < 0x193)
17447
2/2
✓ Branch 0 taken 362010 times.
✓ Branch 1 taken 32910 times.
394920 for(int32_t q=0; q<11; q++)
17448
2/4
✓ Branch 0 taken 362010 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 362010 times.
✗ Branch 3 not taken.
362010 if(!p_getc(&dummy,f))
17449 32910 return qe_invalid;
17450 7402851 }
17451
17452 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17453
3/6
✓ Branch 0 taken 4514443 times.
✓ Branch 1 taken 2925272 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4514443 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7439715 if((version < 0x211)||((version == 0x211)&&(build<7)))
17454 {
17455
2/2
✓ Branch 0 taken 2885336 times.
✓ Branch 1 taken 39936 times.
2925272 if(!get_qr(qr_NEWENEMYTILES))
17456 {
17457
1/5
✓ Branch 0 taken 39936 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
39936 switch(temp_combo.tile)
17458 {
17459 case 130:
17460 temp_combo.tile = 132;
17461 break;
17462
17463 case 131:
17464 temp_combo.tile = 133;
17465 break;
17466
17467 case 132:
17468 temp_combo.tile = 130;
17469 break;
17470
17471 case 133:
17472 temp_combo.tile = 131;
17473 break;
17474 }
17475 39936 }
17476 2925272 }
17477
17478
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7236747 times.
7439715 if(section_version < 15)
17479 7236747 temp_combo.o_tile = temp_combo.tile;
17480
17481
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7236747 times.
7439715 if(section_version<18) //upper bits for .walk
17482 7236747 temp_combo.walk |= 0xF0;
17483
17484
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7236747 times.
7439715 if(section_version < 19)
17485
2/2
✓ Branch 0 taken 28946988 times.
✓ Branch 1 taken 7236747 times.
36183735 for(int32_t q = 0; q < 4; ++q)
17486 36183735 temp_combo.attributes[q] *= 10000L;
17487
17488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7439715 times.
7439715 if(section_version < 23)
17489 {
17490
2/2
✓ Branch 0 taken 14731 times.
✓ Branch 1 taken 7424984 times.
7439715 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17491 {
17492 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17493 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17494 case cTRIGGERGENERIC: case cCSWITCH:
17495 14731 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
17496 14731 }
17497 7439715 }
17498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7439715 times.
7439715 if(section_version < 25)
17499 {
17500
2/2
✓ Branch 0 taken 26963 times.
✓ Branch 1 taken 7412752 times.
7439715 switch(temp_combo.type)
17501 {
17502 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
17503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26963 times.
26963 if(!(temp_combo.usrflags & cflag3))
17504 26963 temp_combo.attribytes[3] = WAV_DOOR;
17505 26963 temp_combo.usrflags &= ~cflag3;
17506 26963 break;
17507 }
17508 7439715 }
17509
17510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7439715 times.
7439715 if(section_version < 26)
17511
2/2
✓ Branch 0 taken 7438615 times.
✓ Branch 1 taken 1100 times.
7440815 if(temp_combo.type == cARMOS)
17512
1/2
✓ Branch 0 taken 1100 times.
✗ Branch 1 not taken.
1100 if(temp_combo.usrflags & cflag1)
17513 temp_combo.usrflags |= cflag3;
17514
17515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7439715 times.
7439715 if(section_version < 27)
17516 {
17517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7439715 times.
7439715 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
17518 temp_combo.trigchange = 1;
17519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7439715 times.
7439715 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
17520 temp_combo.trigchange = -1;
17521 7439715 else temp_combo.trigchange = 0;
17522 7439715 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
17523 7439715 }
17524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7439715 times.
7439715 if(section_version < 28)
17525 {
17526
2/2
✓ Branch 0 taken 15216 times.
✓ Branch 1 taken 7424499 times.
7439715 switch(temp_combo.type)
17527 {
17528 case cLOCKBLOCK: case cLOCKEDCHEST:
17529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15216 times.
15216 if(temp_combo.usrflags & cflag7)
17530 temp_combo.usrflags |= cflag8;
17531 15216 else temp_combo.usrflags &= ~cflag8;
17532 15216 temp_combo.usrflags &= ~cflag7;
17533 15216 break;
17534 }
17535
2/2
✓ Branch 0 taken 751 times.
✓ Branch 1 taken 7438964 times.
7439715 switch(temp_combo.type)
17536 {
17537 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
17538 751 temp_combo.attrishorts[2] = -1;
17539 751 temp_combo.usrflags |= cflag7;
17540 751 break;
17541 }
17542 7439715 }
17543
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7236747 times.
7439715 if(section_version < 20)
17544 {
17545 7236747 temp_combo.genflags = 0;
17546
2/2
✓ Branch 0 taken 141882 times.
✓ Branch 1 taken 7094865 times.
7236747 switch(temp_combo.type)
17547 {
17548 case cPUSH_WAIT: case cPUSH_HEAVY:
17549 case cPUSH_HW: case cL_STATUE:
17550 case cR_STATUE: case cPUSH_HEAVY2:
17551 case cPUSH_HW2: case cPOUND:
17552 case cC_STATUE: case cMIRROR:
17553 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17554 case cMAGICPRISM: case cMAGICPRISM4:
17555 case cMAGICSPONGE: case cEYEBALL_A:
17556 case cEYEBALL_B: case cEYEBALL_4:
17557 case cBUSH: case cFLOWERS:
17558 case cLOCKBLOCK: case cLOCKBLOCK2:
17559 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17560 case cCHEST: case cCHEST2:
17561 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17562 case cBOSSCHEST: case cBOSSCHEST2:
17563 case cBUSHNEXT: case cBUSHTOUCHY:
17564 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17565 case cSIGNPOST: case cCSWITCHBLOCK:
17566 case cTORCH: case cTRIGGERGENERIC:
17567
1/2
✓ Branch 0 taken 141882 times.
✗ Branch 1 not taken.
141882 if(temp_combo.usrflags & cflag16)
17568 {
17569 temp_combo.genflags |= cflag1;
17570 temp_combo.usrflags &= ~cflag16;
17571 }
17572 141882 break;
17573 }
17574 7236747 }
17575
17576 7439715 update_combo(temp_combo, section_version);
17577
17578
3/4
✓ Branch 0 taken 7439715 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7424796 times.
✓ Branch 3 taken 14919 times.
7439715 if(i>=start_combo && !should_skip)
17579 {
17580
1/2
✓ Branch 0 taken 7424796 times.
✗ Branch 1 not taken.
7424796 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17581 {
17582 temp_combo.script = 0;
17583 for(int q = 0; q < 8; ++q)
17584 temp_combo.initd[q] = 0;
17585 }
17586
1/2
✓ Branch 0 taken 7424796 times.
✗ Branch 1 not taken.
7424796 combobuf[i] = temp_combo;
17587 7424796 }
17588 7439715 }
17589
17590
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 1 times.
277 if (should_skip)
17591 1 return 0;
17592
17593
5/6
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 253 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
276 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
17594 {
17595
2/2
✓ Branch 0 taken 1501440 times.
✓ Branch 1 taken 23 times.
1501463 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17596 {
17597
2/2
✓ Branch 0 taken 1501225 times.
✓ Branch 1 taken 215 times.
1501440 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
17598 {
17599 215 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
17600 215 }
17601 1501440 }
17602 23 }
17603
17604 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
17605
4/6
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 217 times.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 59 times.
276 if(version == 0x210 && !is_editor())
17606 {
17607
2/2
✓ Branch 0 taken 3851520 times.
✓ Branch 1 taken 59 times.
3851579 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17608
2/2
✓ Branch 0 taken 3851335 times.
✓ Branch 1 taken 185 times.
3851705 if(combobuf[tmpcounter].type == cLADDERONLY)
17609 185 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
17610 59 }
17611
17612
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 82 times.
276 if(section_version<7)
17613 {
17614
2/2
✓ Branch 0 taken 5352960 times.
✓ Branch 1 taken 82 times.
5353042 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17615 {
17616
6/9
✓ Branch 0 taken 5350008 times.
✓ Branch 1 taken 853 times.
✓ Branch 2 taken 791 times.
✓ Branch 3 taken 603 times.
✓ Branch 4 taken 174 times.
✓ Branch 5 taken 531 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
5352960 switch(combobuf[tmpcounter].type)
17617 {
17618 case cSLASH:
17619 853 combobuf[tmpcounter].type=cSLASHTOUCHY;
17620 853 break;
17621
17622 case cSLASHITEM:
17623 791 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
17624 791 break;
17625
17626 case cBUSH:
17627 603 combobuf[tmpcounter].type=cBUSHTOUCHY;
17628 603 break;
17629
17630 case cFLOWERS:
17631 174 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
17632 174 break;
17633
17634 case cTALLGRASS:
17635 531 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
17636 531 break;
17637
17638 case cSLASHNEXT:
17639 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
17640 break;
17641
17642 case cSLASHNEXTITEM:
17643 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
17644 break;
17645
17646 case cBUSHNEXT:
17647 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
17648 break;
17649 }
17650 5352960 }
17651 82 }
17652
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 271 times.
276 if (section_version < 16)
17653 {
17654
2/2
✓ Branch 0 taken 17690880 times.
✓ Branch 1 taken 271 times.
17691151 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17655 {
17656
2/2
✓ Branch 0 taken 17662235 times.
✓ Branch 1 taken 28645 times.
17690880 if (combobuf[tmpcounter].type == cWATER)
17657 {
17658 28645 combobuf[tmpcounter].attributes[0] = 40000L;
17659 28645 }
17660 17690880 }
17661 271 }
17662
2/2
✓ Branch 0 taken 273 times.
✓ Branch 1 taken 3 times.
276 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
17663 {
17664 3 combobuf[0].walk = 0xF0;
17665 3 combobuf[0].type = 0;
17666 3 combobuf[0].flag = 0;
17667 3 }
17668
17669 //Now for the new combo alias reset
17670
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 82 times.
276 if(section_version<2)
17671 {
17672
2/2
✓ Branch 0 taken 671744 times.
✓ Branch 1 taken 82 times.
671826 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
17673 {
17674 671744 combo_aliases[j].width = 0;
17675 671744 combo_aliases[j].height = 0;
17676 671744 combo_aliases[j].layermask = 0;
17677
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].combos.clear();
17678
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].csets.clear();
17679 671744 }
17680 82 }
17681
17682
17683
1/2
✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
276 setup_combo_animations();
17684
1/2
✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
276 setup_combo_animations2();
17685 276 return 0;
17686 277 }
17687 2402053 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
17688 {
17689 byte combo_has_flags;
17690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2402053 times.
2402053 if(!p_getc(&combo_has_flags,f))
17691 return qe_invalid;
17692
17693 2402053 temp_combo.clear();
17694
2/2
✓ Branch 0 taken 1672327 times.
✓ Branch 1 taken 729726 times.
2402053 if(combo_has_flags)
17695 {
17696
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 729669 times.
729726 if(combo_has_flags&CHAS_BASIC)
17697 {
17698
1/2
✓ Branch 0 taken 729669 times.
✗ Branch 1 not taken.
729669 if(!p_igetl(&temp_combo.tile,f))
17699 return qe_invalid;
17700 729669 temp_combo.o_tile = temp_combo.tile;
17701
17702
1/2
✓ Branch 0 taken 729669 times.
✗ Branch 1 not taken.
729669 if(!p_getc(&temp_combo.flip,f))
17703 return qe_invalid;
17704
17705
1/2
✓ Branch 0 taken 729669 times.
✗ Branch 1 not taken.
729669 if(!p_getc(&temp_combo.walk,f))
17706 return qe_invalid;
17707
17708
1/2
✓ Branch 0 taken 729669 times.
✗ Branch 1 not taken.
729669 if(!p_getc(&temp_combo.type,f))
17709 return qe_invalid;
17710
17711
1/2
✓ Branch 0 taken 729669 times.
✗ Branch 1 not taken.
729669 if(!p_getc(&temp_combo.flag,f))
17712 return qe_invalid;
17713
17714
1/2
✓ Branch 0 taken 729669 times.
✗ Branch 1 not taken.
729669 if(!p_getc(&temp_combo.csets,f))
17715 return qe_invalid;
17716 729669 }
17717
2/2
✓ Branch 0 taken 726912 times.
✓ Branch 1 taken 2814 times.
729726 if(combo_has_flags&CHAS_SCRIPT)
17718 {
17719
2/2
✓ Branch 0 taken 2784 times.
✓ Branch 1 taken 30 times.
2814 if (s_version>=41)
17720 {
17721 2784 p_getcstr(&temp_combo.label, f);
17722 2784 }
17723 else
17724 {
17725 char label[12];
17726 30 label[11] = '\0';
17727
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 30 times.
360 for ( int32_t q = 0; q < 11; q++ )
17728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330 times.
330 if(!p_getc(&label[q],f))
17729 return qe_invalid;
17730 30 temp_combo.label = label;
17731 }
17732
17733
1/2
✓ Branch 0 taken 2814 times.
✗ Branch 1 not taken.
2814 if(!p_igetw(&temp_combo.script,f)) return qe_invalid;
17734 2814 auto initd_count = s_version >= 43 ? 8 : 2;
17735
2/2
✓ Branch 0 taken 22332 times.
✓ Branch 1 taken 2814 times.
25146 for ( int32_t q = 0; q < initd_count; q++ )
17736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22332 times.
22332 if(!p_igetl(&temp_combo.initd[q],f))
17737 return qe_invalid;
17738 2814 }
17739
2/2
✓ Branch 0 taken 577707 times.
✓ Branch 1 taken 152019 times.
729726 if(combo_has_flags&CHAS_ANIM)
17740 {
17741
1/2
✓ Branch 0 taken 152019 times.
✗ Branch 1 not taken.
152019 if(!p_getc(&temp_combo.frames,f))
17742 return qe_invalid;
17743
17744
1/2
✓ Branch 0 taken 152019 times.
✗ Branch 1 not taken.
152019 if(!p_getc(&temp_combo.speed,f))
17745 return qe_invalid;
17746
17747
1/2
✓ Branch 0 taken 152019 times.
✗ Branch 1 not taken.
152019 if(!p_igetw(&temp_combo.nextcombo,f))
17748 return qe_invalid;
17749
17750
1/2
✓ Branch 0 taken 152019 times.
✗ Branch 1 not taken.
152019 if(!p_getc(&temp_combo.nextcset,f))
17751 return qe_invalid;
17752
17753
1/2
✓ Branch 0 taken 152019 times.
✗ Branch 1 not taken.
152019 if(!p_getc(&temp_combo.skipanim,f))
17754 return qe_invalid;
17755
17756
1/2
✓ Branch 0 taken 152019 times.
✗ Branch 1 not taken.
152019 if(!p_getc(&temp_combo.skipanimy,f))
17757 return qe_invalid;
17758
17759
1/2
✓ Branch 0 taken 152019 times.
✗ Branch 1 not taken.
152019 if(!p_getc(&temp_combo.animflags,f))
17760 return qe_invalid;
17761 152019 }
17762
2/2
✓ Branch 0 taken 648017 times.
✓ Branch 1 taken 81709 times.
729726 if(combo_has_flags&CHAS_ATTRIB)
17763 {
17764
2/2
✓ Branch 0 taken 326836 times.
✓ Branch 1 taken 81709 times.
408545 for ( int32_t q = 0; q < 4; q++ )
17765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 326836 times.
326836 if(!p_igetl(&temp_combo.attributes[q],f))
17766 return qe_invalid;
17767
2/2
✓ Branch 0 taken 653672 times.
✓ Branch 1 taken 81709 times.
735381 for ( int32_t q = 0; q < 8; q++ )
17768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 653672 times.
653672 if(!p_getc(&temp_combo.attribytes[q],f))
17769 return qe_invalid;
17770
2/2
✓ Branch 0 taken 653672 times.
✓ Branch 1 taken 81709 times.
735381 for ( int32_t q = 0; q < 8; q++ )
17771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 653672 times.
653672 if(!p_igetw(&temp_combo.attrishorts[q],f))
17772 return qe_invalid;
17773 81709 }
17774
2/2
✓ Branch 0 taken 701638 times.
✓ Branch 1 taken 28088 times.
729726 if(combo_has_flags&CHAS_FLAG)
17775 {
17776
1/2
✓ Branch 0 taken 28088 times.
✗ Branch 1 not taken.
28088 if(!p_igetl(&temp_combo.usrflags,f))
17777 return qe_invalid;
17778
1/2
✓ Branch 0 taken 28088 times.
✗ Branch 1 not taken.
28088 if(!p_igetw(&temp_combo.genflags,f))
17779 return qe_invalid;
17780 28088 }
17781
2/2
✓ Branch 0 taken 712920 times.
✓ Branch 1 taken 16806 times.
729726 if(combo_has_flags&CHAS_TRIG)
17782 {
17783 16806 int numtrigs = s_version < 36 ? 3 : 6;
17784
2/2
✓ Branch 0 taken 99978 times.
✓ Branch 1 taken 16806 times.
116784 for ( int32_t q = 0; q < numtrigs; q++ )
17785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99978 times.
99978 if(!p_igetl(&temp_combo.triggerflags[q],f))
17786 return qe_invalid;
17787
1/2
✓ Branch 0 taken 16806 times.
✗ Branch 1 not taken.
16806 if(!p_igetl(&temp_combo.triggerlevel,f))
17788 return qe_invalid;
17789
1/2
✓ Branch 0 taken 16806 times.
✗ Branch 1 not taken.
16806 if(!p_getc(&temp_combo.triggerbtn,f))
17790 return qe_invalid;
17791
1/2
✓ Branch 0 taken 16806 times.
✗ Branch 1 not taken.
16806 if(!p_getc(&temp_combo.triggeritem,f))
17792 return qe_invalid;
17793
1/2
✓ Branch 0 taken 16806 times.
✗ Branch 1 not taken.
16806 if(!p_getc(&temp_combo.trigtimer,f))
17794 return qe_invalid;
17795
1/2
✓ Branch 0 taken 16806 times.
✗ Branch 1 not taken.
16806 if(!p_getc(&temp_combo.trigsfx,f))
17796 return qe_invalid;
17797
1/2
✓ Branch 0 taken 16806 times.
✗ Branch 1 not taken.
16806 if(!p_igetl(&temp_combo.trigchange,f))
17798 return qe_invalid;
17799
1/2
✓ Branch 0 taken 16806 times.
✗ Branch 1 not taken.
16806 if(!p_igetw(&temp_combo.trigprox,f))
17800 return qe_invalid;
17801
1/2
✓ Branch 0 taken 16806 times.
✗ Branch 1 not taken.
16806 if(!p_getc(&temp_combo.trigctr,f))
17802 return qe_invalid;
17803
1/2
✓ Branch 0 taken 16806 times.
✗ Branch 1 not taken.
16806 if(!p_igetl(&temp_combo.trigctramnt,f))
17804 return qe_invalid;
17805
1/2
✓ Branch 0 taken 16806 times.
✗ Branch 1 not taken.
16806 if(!p_getc(&temp_combo.triglbeam,f))
17806 return qe_invalid;
17807
1/2
✓ Branch 0 taken 16806 times.
✗ Branch 1 not taken.
16806 if(!p_getc(&temp_combo.trigcschange,f))
17808 return qe_invalid;
17809
1/2
✓ Branch 0 taken 16806 times.
✗ Branch 1 not taken.
16806 if(!p_igetw(&temp_combo.spawnitem,f))
17810 return qe_invalid;
17811
1/2
✓ Branch 0 taken 16806 times.
✗ Branch 1 not taken.
16806 if(!p_igetw(&temp_combo.spawnenemy,f))
17812 return qe_invalid;
17813
1/2
✓ Branch 0 taken 16806 times.
✗ Branch 1 not taken.
16806 if(!p_getc(&temp_combo.exstate,f))
17814 return qe_invalid;
17815
1/2
✓ Branch 0 taken 16806 times.
✗ Branch 1 not taken.
16806 if(!p_igetl(&temp_combo.spawnip,f))
17816 return qe_invalid;
17817
1/2
✓ Branch 0 taken 16806 times.
✗ Branch 1 not taken.
16806 if(!p_getc(&temp_combo.trigcopycat,f))
17818 return qe_invalid;
17819
1/2
✓ Branch 0 taken 16806 times.
✗ Branch 1 not taken.
16806 if(!p_getc(&temp_combo.trigcooldown,f))
17820 return qe_invalid;
17821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16806 times.
16806 if(s_version >= 35)
17822 {
17823
1/2
✓ Branch 0 taken 16806 times.
✗ Branch 1 not taken.
16806 if(!p_igetw(&temp_combo.prompt_cid,f))
17824 return qe_invalid;
17825
1/2
✓ Branch 0 taken 16806 times.
✗ Branch 1 not taken.
16806 if(!p_getc(&temp_combo.prompt_cs,f))
17826 return qe_invalid;
17827
1/2
✓ Branch 0 taken 16806 times.
✗ Branch 1 not taken.
16806 if(!p_igetw(&temp_combo.prompt_x,f))
17828 return qe_invalid;
17829
1/2
✓ Branch 0 taken 16806 times.
✗ Branch 1 not taken.
16806 if(!p_igetw(&temp_combo.prompt_y,f))
17830 return qe_invalid;
17831 16806 }
17832
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 16520 times.
16806 if(s_version >= 36)
17833 {
17834
1/2
✓ Branch 0 taken 16520 times.
✗ Branch 1 not taken.
16520 if(!p_getc(&temp_combo.trig_lstate,f))
17835 return qe_invalid;
17836
1/2
✓ Branch 0 taken 16520 times.
✗ Branch 1 not taken.
16520 if(!p_getc(&temp_combo.trig_gstate,f))
17837 return qe_invalid;
17838
1/2
✓ Branch 0 taken 16520 times.
✗ Branch 1 not taken.
16520 if(!p_igetl(&temp_combo.trig_statetime,f))
17839 return qe_invalid;
17840 16520 }
17841
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 16520 times.
16806 if(s_version >= 37)
17842 {
17843
1/2
✓ Branch 0 taken 16520 times.
✗ Branch 1 not taken.
16520 if(!p_igetw(&temp_combo.trig_genscr,f))
17844 return qe_invalid;
17845 16520 }
17846
2/2
✓ Branch 0 taken 434 times.
✓ Branch 1 taken 16372 times.
16806 if(s_version >= 38)
17847 {
17848
1/2
✓ Branch 0 taken 16372 times.
✗ Branch 1 not taken.
16372 if(!p_getc(&temp_combo.trig_group,f))
17849 return qe_invalid;
17850
1/2
✓ Branch 0 taken 16372 times.
✗ Branch 1 not taken.
16372 if(!p_igetw(&temp_combo.trig_group_val,f))
17851 return qe_invalid;
17852 16372 }
17853
2/2
✓ Branch 0 taken 479 times.
✓ Branch 1 taken 16327 times.
16806 if(s_version >= 45)
17854 {
17855
1/2
✓ Branch 0 taken 16327 times.
✗ Branch 1 not taken.
16327 if(!p_getc(&temp_combo.exdoor_dir,f))
17856 return qe_invalid;
17857
1/2
✓ Branch 0 taken 16327 times.
✗ Branch 1 not taken.
16327 if(!p_getc(&temp_combo.exdoor_ind,f))
17858 return qe_invalid;
17859 16327 }
17860
2/2
✓ Branch 0 taken 12745 times.
✓ Branch 1 taken 4061 times.
16806 if(s_version >= 46)
17861 {
17862
1/2
✓ Branch 0 taken 4061 times.
✗ Branch 1 not taken.
4061 if(!p_getc(&temp_combo.trig_levelitems,f))
17863 return qe_invalid;
17864
1/2
✓ Branch 0 taken 4061 times.
✗ Branch 1 not taken.
4061 if(!p_igetw(&temp_combo.trigdmlevel,f))
17865 return qe_invalid;
17866
2/2
✓ Branch 0 taken 1355 times.
✓ Branch 1 taken 2706 times.
4061 if(s_version >= 48)
17867 {
17868
2/2
✓ Branch 0 taken 4065 times.
✓ Branch 1 taken 1355 times.
5420 for(int q = 0; q < 3; ++q)
17869
1/2
✓ Branch 0 taken 4065 times.
✗ Branch 1 not taken.
4065 if(!p_igetw(&temp_combo.trigtint[q],f))
17870 return qe_invalid;
17871 1355 }
17872 else
17873 {
17874
2/2
✓ Branch 0 taken 8118 times.
✓ Branch 1 taken 2706 times.
10824 for(int q = 0; q < 3; ++q)
17875
1/2
✓ Branch 0 taken 8118 times.
✗ Branch 1 not taken.
8118 if(!p_getc(&temp_combo.trigtint[q],f))
17876 return qe_invalid;
17877
2/2
✓ Branch 0 taken 8118 times.
✓ Branch 1 taken 2706 times.
10824 for(int q = 0; q < 3; ++q)
17878 {
17879 8118 int v = temp_combo.trigtint[q];
17880 8118 int va = abs(v);
17881 8118 temp_combo.trigtint[q] = _rgb_scale_6[va] * sign(v);
17882 8118 }
17883 }
17884
1/2
✓ Branch 0 taken 4061 times.
✗ Branch 1 not taken.
4061 if(!p_igetw(&temp_combo.triglvlpalette,f))
17885 return qe_invalid;
17886
1/2
✓ Branch 0 taken 4061 times.
✗ Branch 1 not taken.
4061 if(!p_igetw(&temp_combo.trigbosspalette,f))
17887 return qe_invalid;
17888
1/2
✓ Branch 0 taken 4061 times.
✗ Branch 1 not taken.
4061 if(!p_igetw(&temp_combo.trigquaketime,f))
17889 return qe_invalid;
17890
1/2
✓ Branch 0 taken 4061 times.
✗ Branch 1 not taken.
4061 if(!p_igetw(&temp_combo.trigwavytime,f))
17891 return qe_invalid;
17892
1/2
✓ Branch 0 taken 4061 times.
✗ Branch 1 not taken.
4061 if(!p_igetw(&temp_combo.trig_swjinxtime,f))
17893 return qe_invalid;
17894
1/2
✓ Branch 0 taken 4061 times.
✗ Branch 1 not taken.
4061 if(!p_igetw(&temp_combo.trig_itmjinxtime,f))
17895 return qe_invalid;
17896
1/2
✓ Branch 0 taken 4061 times.
✗ Branch 1 not taken.
4061 if(!p_igetw(&temp_combo.trig_stuntime,f))
17897 return qe_invalid;
17898
1/2
✓ Branch 0 taken 4061 times.
✗ Branch 1 not taken.
4061 if(!p_igetw(&temp_combo.trig_bunnytime,f))
17899 return qe_invalid;
17900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4061 times.
4061 if(!p_getc(&temp_combo.trig_pushtime,f))
17901 return qe_invalid;
17902 4061 }
17903
2/2
✓ Branch 0 taken 15451 times.
✓ Branch 1 taken 1355 times.
16806 if(s_version >= 47)
17904 {
17905
1/2
✓ Branch 0 taken 1355 times.
✗ Branch 1 not taken.
1355 if (!p_igetw(&temp_combo.trig_shieldjinxtime, f))
17906 return qe_invalid;
17907 1355 }
17908 16806 }
17909
2/2
✓ Branch 0 taken 727599 times.
✓ Branch 1 taken 2127 times.
729726 if(combo_has_flags&CHAS_LIFT)
17910 {
17911
1/2
✓ Branch 0 taken 2127 times.
✗ Branch 1 not taken.
2127 if(!p_igetw(&temp_combo.liftcmb,f))
17912 return qe_invalid;
17913
1/2
✓ Branch 0 taken 2127 times.
✗ Branch 1 not taken.
2127 if(!p_getc(&temp_combo.liftcs,f))
17914 return qe_invalid;
17915
1/2
✓ Branch 0 taken 2127 times.
✗ Branch 1 not taken.
2127 if(!p_igetw(&temp_combo.liftundercmb,f))
17916 return qe_invalid;
17917
1/2
✓ Branch 0 taken 2127 times.
✗ Branch 1 not taken.
2127 if(!p_getc(&temp_combo.liftundercs,f))
17918 return qe_invalid;
17919
1/2
✓ Branch 0 taken 2127 times.
✗ Branch 1 not taken.
2127 if(!p_getc(&temp_combo.liftdmg,f))
17920 return qe_invalid;
17921
1/2
✓ Branch 0 taken 2127 times.
✗ Branch 1 not taken.
2127 if(!p_getc(&temp_combo.liftlvl,f))
17922 return qe_invalid;
17923
1/2
✓ Branch 0 taken 2127 times.
✗ Branch 1 not taken.
2127 if(!p_getc(&temp_combo.liftitm,f))
17924 return qe_invalid;
17925
1/2
✓ Branch 0 taken 2127 times.
✗ Branch 1 not taken.
2127 if(!p_getc(&temp_combo.liftflags,f))
17926 return qe_invalid;
17927
1/2
✓ Branch 0 taken 2127 times.
✗ Branch 1 not taken.
2127 if(!p_getc(&temp_combo.liftgfx,f))
17928 return qe_invalid;
17929
1/2
✓ Branch 0 taken 2127 times.
✗ Branch 1 not taken.
2127 if(!p_getc(&temp_combo.liftsprite,f))
17930 return qe_invalid;
17931
1/2
✓ Branch 0 taken 2127 times.
✗ Branch 1 not taken.
2127 if(!p_getc(&temp_combo.liftsfx,f))
17932 return qe_invalid;
17933
1/2
✓ Branch 0 taken 2127 times.
✗ Branch 1 not taken.
2127 if(!p_igetw(&temp_combo.liftbreaksprite,f))
17934 return qe_invalid;
17935
1/2
✓ Branch 0 taken 2127 times.
✗ Branch 1 not taken.
2127 if(!p_getc(&temp_combo.liftbreaksfx,f))
17936 return qe_invalid;
17937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2127 times.
2127 if(s_version >= 34)
17938 {
17939
1/2
✓ Branch 0 taken 2127 times.
✗ Branch 1 not taken.
2127 if(!p_getc(&temp_combo.lifthei,f))
17940 return qe_invalid;
17941
1/2
✓ Branch 0 taken 2127 times.
✗ Branch 1 not taken.
2127 if(!p_getc(&temp_combo.lifttime,f))
17942 return qe_invalid;
17943 2127 }
17944
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 2113 times.
2127 if(s_version >= 39)
17945 {
17946
1/2
✓ Branch 0 taken 2113 times.
✗ Branch 1 not taken.
2113 if(!p_getc(&temp_combo.lift_parent_item,f))
17947 return qe_invalid;
17948 2113 }
17949 2127 }
17950
2/2
✓ Branch 0 taken 728424 times.
✓ Branch 1 taken 1302 times.
729726 if(combo_has_flags&CHAS_GENERAL)
17951 {
17952
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!p_getc(&temp_combo.speed_mult,f))
17953 return qe_invalid;
17954
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!p_getc(&temp_combo.speed_div,f))
17955 return qe_invalid;
17956
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!p_igetzf(&temp_combo.speed_add,f))
17957 return qe_invalid;
17958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1302 times.
1302 if(s_version >= 42)
17959 {
17960
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!p_getc(&temp_combo.sfx_appear,f))
17961 return qe_invalid;
17962
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!p_getc(&temp_combo.sfx_disappear,f))
17963 return qe_invalid;
17964
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!p_getc(&temp_combo.sfx_loop,f))
17965 return qe_invalid;
17966
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!p_getc(&temp_combo.sfx_walking,f))
17967 return qe_invalid;
17968
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!p_getc(&temp_combo.sfx_standing,f))
17969 return qe_invalid;
17970
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!p_getc(&temp_combo.spr_appear,f))
17971 return qe_invalid;
17972
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!p_getc(&temp_combo.spr_disappear,f))
17973 return qe_invalid;
17974
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!p_getc(&temp_combo.spr_walking,f))
17975 return qe_invalid;
17976
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!p_getc(&temp_combo.spr_standing,f))
17977 return qe_invalid;
17978 1302 }
17979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1302 times.
1302 if(s_version >= 44)
17980 {
17981
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!p_getc(&temp_combo.sfx_tap,f))
17982 return qe_invalid;
17983 1302 }
17984 1302 }
17985 729726 }
17986 2402053 update_combo(temp_combo, s_version);
17987 2402053 return 0;
17988 2402053 }
17989 693 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos)
17990 {
17991
2/2
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 24 times.
693 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
17992
17993 693 word section_version=0;
17994 693 word section_cversion=0;
17995 693 word combos_used=0;
17996 int32_t dummy;
17997 byte padding;
17998 693 newcombo temp_combo;
17999
18000
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 692 times.
693 if (!should_skip)
18001 {
18002
1/2
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
692 reset_combo_animations();
18003
1/2
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
692 reset_combo_animations2();
18004
1/2
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
692 init_combo_classes();
18005
18006
2/2
✓ Branch 0 taken 45173760 times.
✓ Branch 1 taken 692 times.
45174452 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18007
1/2
✓ Branch 0 taken 45173760 times.
✗ Branch 1 not taken.
45173760 combobuf[q].clear();
18008 692 }
18009
18010
2/2
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 24 times.
693 if(version > 0x192) //Version info
18011 {
18012
2/4
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 669 times.
✗ Branch 3 not taken.
669 if(!p_igetw(&section_version,f))
18013 {
18014 return qe_invalid;
18015 }
18016 669 FFCore.quest_format[vCombos] = section_version;
18017
2/4
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 669 times.
✗ Branch 3 not taken.
669 if(!p_igetw(&section_cversion,f))
18018 {
18019 return qe_invalid;
18020 }
18021
18022 //section size
18023
2/4
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 669 times.
✗ Branch 3 not taken.
669 if(!p_igetl(&dummy,f))
18024 {
18025 return qe_invalid;
18026 }
18027 669 }
18028
18029
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 277 times.
693 if(section_version > 32) //Cleanup time!
18030 {
18031
2/4
✓ Branch 0 taken 416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 416 times.
✗ Branch 3 not taken.
416 if(!p_igetw(&combos_used,f))
18032 {
18033 return qe_invalid;
18034 }
18035
2/2
✓ Branch 0 taken 2402053 times.
✓ Branch 1 taken 416 times.
2402469 for(int32_t i=0; i<combos_used; i++)
18036 {
18037
1/2
✓ Branch 0 taken 2402053 times.
✗ Branch 1 not taken.
2402053 auto ret = readcombo_loop(f,section_version,temp_combo);
18038
1/2
✓ Branch 0 taken 2402053 times.
✗ Branch 1 not taken.
2402053 if(ret) return ret;
18039
1/2
✓ Branch 0 taken 2402053 times.
✗ Branch 1 not taken.
2402053 if(i>=start_combo)
18040 {
18041
1/2
✓ Branch 0 taken 2402053 times.
✗ Branch 1 not taken.
2402053 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
18042 {
18043 temp_combo.script = 0;
18044 for(int q = 0; q < 8; ++q)
18045 temp_combo.initd[q] = 0;
18046 }
18047
1/2
✓ Branch 0 taken 2402053 times.
✗ Branch 1 not taken.
2402053 combobuf[i] = temp_combo;
18048 2402053 }
18049 2402053 }
18050 416 }
18051 else //Call the old function for all old versions
18052 {
18053
1/2
✓ Branch 0 taken 277 times.
✗ Branch 1 not taken.
277 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos);
18054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 277 times.
277 if(ret) return ret; //error, end read
18055 }
18056
18057
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 1 times.
693 if (should_skip)
18058 1 return 0;
18059
18060
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 409 times.
692 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18061 {
18062 409 combobuf[0].walk = 0xF0;
18063 409 combobuf[0].type = 0;
18064 409 combobuf[0].flag = 0;
18065 409 }
18066
18067
1/2
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
692 setup_combo_animations();
18068
1/2
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
692 setup_combo_animations2();
18069 692 return 0;
18070 693 }
18071
18072 610 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build)
18073 {
18074 //these are here to bypass compiler warnings about unused arguments
18075 610 Header=Header;
18076 610 version=version;
18077 610 build=build;
18078
18079 int32_t dummy;
18080 610 word sversion=0, c_sversion;
18081
18082 //section version info
18083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if(!p_igetw(&sversion,f))
18084 {
18085 return qe_invalid;
18086 }
18087
18088 610 FFCore.quest_format[vComboAliases] = sversion;
18089
18090
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_igetw(&c_sversion,f))
18091 {
18092 return qe_invalid;
18093 }
18094
18095 //section size
18096
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_igetl(&dummy,f))
18097 {
18098 return qe_invalid;
18099 }
18100
18101 610 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18102
18103
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 189 times.
610 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18104 {
18105 189 max_num_combo_aliases = MAX250COMBOALIASES;
18106 189 }
18107
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18108 {
18109 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18110 }
18111
18112
2/2
✓ Branch 0 taken 3835904 times.
✓ Branch 1 taken 610 times.
3836514 for(int32_t j=0; j<max_num_combo_aliases; j++)
18113 {
18114 byte width,height,mask,tempcset;
18115 int32_t count;
18116 word tempword;
18117 byte tempbyte;
18118
18119
1/2
✓ Branch 0 taken 3835904 times.
✗ Branch 1 not taken.
3835904 if(!p_igetw(&tempword,f))
18120 {
18121 return qe_invalid;
18122 }
18123
18124 3835904 combo_aliases[j].combo = tempword;
18125
18126
1/2
✓ Branch 0 taken 3835904 times.
✗ Branch 1 not taken.
3835904 if(!p_getc(&tempbyte,f))
18127 {
18128 return qe_invalid;
18129 }
18130
18131 3835904 combo_aliases[j].cset = tempbyte;
18132
18133
1/2
✓ Branch 0 taken 3835904 times.
✗ Branch 1 not taken.
3835904 if(!p_getc(&width,f))
18134 {
18135 return qe_invalid;
18136 }
18137
18138
1/2
✓ Branch 0 taken 3835904 times.
✗ Branch 1 not taken.
3835904 if(!p_getc(&height,f))
18139 {
18140 return qe_invalid;
18141 }
18142
18143
1/2
✓ Branch 0 taken 3835904 times.
✗ Branch 1 not taken.
3835904 if(!p_getc(&mask,f))
18144 {
18145 return qe_invalid;
18146 }
18147
18148 3835904 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18149
18150 3835904 combo_aliases[j].width = width;
18151 3835904 combo_aliases[j].height = height;
18152 3835904 combo_aliases[j].layermask = mask;
18153 3835904 combo_aliases[j].combos.clear();
18154 3835904 combo_aliases[j].csets.clear();
18155
18156
2/2
✓ Branch 0 taken 3943824 times.
✓ Branch 1 taken 3835904 times.
7779728 for(int32_t k=0; k<count; k++)
18157 {
18158
1/2
✓ Branch 0 taken 3943824 times.
✗ Branch 1 not taken.
3943824 if(!p_igetw(&tempword,f))
18159 {
18160 return qe_invalid;
18161 }
18162
18163 3943824 combo_aliases[j].combos[k] = tempword;
18164 3943824 }
18165
18166
2/2
✓ Branch 0 taken 3943824 times.
✓ Branch 1 taken 3835904 times.
7779728 for(int32_t k=0; k<count; k++)
18167 {
18168
1/2
✓ Branch 0 taken 3943824 times.
✗ Branch 1 not taken.
3943824 if(!p_getc(&tempcset,f))
18169 {
18170 return qe_invalid;
18171 }
18172
18173 3943824 combo_aliases[j].csets[k] = tempcset;
18174 3943824 }
18175 3835904 }
18176
18177 //Combo pools!
18178 610 word num_combo_pools = 0;
18179
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 416 times.
610 if(sversion >= 4)
18180 {
18181
1/2
✓ Branch 0 taken 416 times.
✗ Branch 1 not taken.
416 if(!p_igetw(&num_combo_pools,f))
18182 {
18183 return qe_invalid;
18184 }
18185 416 }
18186
18187
2/2
✓ Branch 0 taken 4997120 times.
✓ Branch 1 taken 610 times.
4997730 for(combo_pool& pool : combo_pools)
18188 {
18189 4997120 pool.clear();
18190 }
18191
18192 610 combo_pool temp_cpool;
18193
2/2
✓ Branch 0 taken 1272 times.
✓ Branch 1 taken 610 times.
1882 for(word cp = 0; cp < num_combo_pools; ++cp)
18194 {
18195 1272 int32_t num_combos_in_pool = 0;
18196
2/4
✓ Branch 0 taken 1272 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1272 times.
✗ Branch 3 not taken.
1272 if(!p_igetl(&num_combos_in_pool,f))
18197 {
18198 return qe_invalid;
18199 }
18200
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 96 times.
1272 if(num_combos_in_pool < 1) continue; //nothing to read
18201
18202
1/2
✓ Branch 0 taken 1176 times.
✗ Branch 1 not taken.
1176 temp_cpool.clear();
18203
18204 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18205
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 5164 times.
6340 for(auto q = 0; q < num_combos_in_pool; ++q)
18206 {
18207
2/4
✓ Branch 0 taken 5164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5164 times.
✗ Branch 3 not taken.
5164 if(!p_igetl(&cp_cid,f))
18208 {
18209 return qe_invalid;
18210 }
18211
2/4
✓ Branch 0 taken 5164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5164 times.
✗ Branch 3 not taken.
5164 if(!p_getc(&cp_cs,f))
18212 {
18213 return qe_invalid;
18214 }
18215
2/4
✓ Branch 0 taken 5164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5164 times.
✗ Branch 3 not taken.
5164 if(!p_igetw(&cp_quant,f))
18216 {
18217 return qe_invalid;
18218 }
18219
1/2
✓ Branch 0 taken 5164 times.
✗ Branch 1 not taken.
5164 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18220 5164 }
18221
18222
1/2
✓ Branch 0 taken 1176 times.
✗ Branch 1 not taken.
1176 combo_pools[cp] = temp_cpool;
18223 1176 }
18224
18225 //Autocombos!
18226 610 word num_combo_autos = 0;
18227
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 207 times.
610 if (sversion >= 5)
18228 {
18229
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if (!p_igetw(&num_combo_autos, f))
18230 {
18231 return qe_invalid;
18232 }
18233 403 }
18234
18235
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 4997120 times.
4997730 for (combo_auto& cauto : combo_autos)
18236 {
18237
1/2
✓ Branch 0 taken 4997120 times.
✗ Branch 1 not taken.
4997120 cauto.clear(true);
18238 }
18239
18240
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 combo_auto temp_cauto;
18241
2/2
✓ Branch 0 taken 891 times.
✓ Branch 1 taken 610 times.
1501 for (word ca = 0; ca < num_combo_autos; ++ca)
18242 {
18243 byte type;
18244 int32_t display_cid, erase_cid;
18245 byte flags, arg;
18246
2/4
✓ Branch 0 taken 891 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 891 times.
✗ Branch 3 not taken.
891 if (!p_getc(&type, f))
18247 {
18248 return qe_invalid;
18249 }
18250
2/4
✓ Branch 0 taken 891 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 891 times.
✗ Branch 3 not taken.
891 if (!p_igetl(&display_cid, f))
18251 {
18252 return qe_invalid;
18253 }
18254
2/4
✓ Branch 0 taken 891 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 891 times.
✗ Branch 3 not taken.
891 if (!p_igetl(&erase_cid, f))
18255 {
18256 return qe_invalid;
18257 }
18258
2/4
✓ Branch 0 taken 891 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 891 times.
✗ Branch 3 not taken.
891 if (!p_getc(&flags, f))
18259 {
18260 return qe_invalid;
18261 }
18262
2/4
✓ Branch 0 taken 891 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 891 times.
✗ Branch 3 not taken.
891 if (!p_getc(&arg, f))
18263 {
18264 return qe_invalid;
18265 }
18266 891 int32_t num_combos_in_cauto = 0;
18267
2/4
✓ Branch 0 taken 891 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 891 times.
✗ Branch 3 not taken.
891 if (!p_igetl(&num_combos_in_cauto, f))
18268 {
18269 return qe_invalid;
18270 }
18271
1/2
✓ Branch 0 taken 891 times.
✗ Branch 1 not taken.
891 if (num_combos_in_cauto < 1) continue; //nothing to read
18272
18273
1/2
✓ Branch 0 taken 891 times.
✗ Branch 1 not taken.
891 temp_cauto.clear();
18274
18275
1/2
✓ Branch 0 taken 891 times.
✗ Branch 1 not taken.
891 temp_cauto.setType(type);
18276
1/2
✓ Branch 0 taken 891 times.
✗ Branch 1 not taken.
891 temp_cauto.setDisplay(display_cid);
18277
1/2
✓ Branch 0 taken 891 times.
✗ Branch 1 not taken.
891 temp_cauto.setEraseCombo(erase_cid);
18278
1/2
✓ Branch 0 taken 891 times.
✗ Branch 1 not taken.
891 temp_cauto.setFlags(flags);
18279
1/2
✓ Branch 0 taken 891 times.
✗ Branch 1 not taken.
891 temp_cauto.setArg(arg);
18280
18281 int32_t ca_cid; byte ca_ctype; int16_t ca_offset; int16_t ca_engrave_offset;
18282
2/2
✓ Branch 0 taken 891 times.
✓ Branch 1 taken 11266 times.
12157 for (auto q = 0; q < num_combos_in_cauto; ++q)
18283 {
18284
2/4
✓ Branch 0 taken 11266 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11266 times.
✗ Branch 3 not taken.
11266 if (!p_getc(&ca_ctype, f))
18285 {
18286 return qe_invalid;
18287 }
18288
2/4
✓ Branch 0 taken 11266 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11266 times.
✗ Branch 3 not taken.
11266 if (!p_igetl(&ca_cid, f))
18289 {
18290 return qe_invalid;
18291 }
18292
1/2
✓ Branch 0 taken 11266 times.
✗ Branch 1 not taken.
11266 temp_cauto.addEntry(ca_cid, ca_ctype, q, -1);
18293 11266 }
18294
18295
1/2
✓ Branch 0 taken 891 times.
✗ Branch 1 not taken.
891 combo_autos[ca] = temp_cauto;
18296 891 }
18297
18298 610 return 0;
18299 610 }
18300
18301 693 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets)
18302 {
18303
2/2
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 24 times.
693 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_colors);
18304
18305 //these are here to bypass compiler warnings about unused arguments
18306 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18307 //Capitalized cause it'll save you a headache. -Deedee
18308 693 start_cset=start_cset;
18309 693 max_csets=max_csets;
18310 693 word s_version=0;
18311
18312 miscQdata temp_misc;
18313 693 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18314
18315 byte temp_colordata[48];
18316 char temp_palname[PALNAMESIZE+1];
18317
18318 int32_t dummy;
18319 word palcycles;
18320
18321
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 669 times.
693 if(version > 0x192)
18322 {
18323 //section version info
18324
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&s_version,f))
18325 {
18326 return qe_invalid;
18327 }
18328
18329 669 FFCore.quest_format[vCSets] = s_version;
18330
18331
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&dummy,f))
18332 {
18333 return qe_invalid;
18334 }
18335
18336 //section size
18337
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetl(&dummy,f))
18338 {
18339 return qe_invalid;
18340 }
18341 669 }
18342
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 421 times.
693 if (s_version < 5)
18343 {
18344
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 254 times.
✓ Branch 2 taken 248 times.
✓ Branch 3 taken 6 times.
272 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18345
18346 //finally... section data
18347 272 int32_t q = 0;
18348 272 int32_t p = -15;
18349
2/2
✓ Branch 0 taken 65280 times.
✓ Branch 1 taken 272 times.
65552 for(int32_t i=0; i<oldpdTOTAL; ++i)
18350 {
18351 65280 memset(temp_colordata, 0, 48);
18352
18353
1/2
✓ Branch 0 taken 65280 times.
✗ Branch 1 not taken.
65280 if(!pfread(temp_colordata,48,f))
18354 {
18355 return qe_invalid;
18356 }
18357
18358
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 65040 times.
65280 if (should_skip)
18359 240 continue;
18360
18361 65040 memcpy(&colordata[q*48], temp_colordata, 48);
18362
18363 65040 ++q;
18364
8/8
✓ Branch 0 taken 60704 times.
✓ Branch 1 taken 4336 times.
✓ Branch 2 taken 4607 times.
✓ Branch 3 taken 56097 times.
✓ Branch 4 taken 542 times.
✓ Branch 5 taken 4065 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 506 times.
65040 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18365 {
18366
1/2
✓ Branch 0 taken 4571 times.
✗ Branch 1 not taken.
4571 if (s_version < 5) //Bumping up the size of level palettes
18367 {
18368 4571 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18369 4571 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18370 4571 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18371 4571 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18372 4571 q+=4;
18373 4571 }
18374 else
18375 {
18376 for(int m = 0; m < 4; ++m)
18377 {
18378 memset(temp_colordata, 0, 48);
18379 if(!pfread(temp_colordata,48,f))
18380 {
18381 return qe_invalid;
18382 }
18383 memcpy(&colordata[q*48], temp_colordata, 48);
18384 ++q;
18385 }
18386 }
18387 4571 }
18388 65040 ++p;
18389 65040 }
18390
18391
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 254 times.
272 if(RealOldVerion)
18392 {
18393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
18394 {
18395 18 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18396 18 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18397 18 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18398 18 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18399 18 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18400 18 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18401 18 }
18402 18 }
18403 else
18404 {
18405 254 memset(temp_colordata, 0, 48);
18406
18407
2/2
✓ Branch 0 taken 795782 times.
✓ Branch 1 taken 254 times.
796036 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18408 {
18409
1/2
✓ Branch 0 taken 795782 times.
✗ Branch 1 not taken.
795782 if(!pfread(temp_colordata,48,f))
18410 {
18411 return qe_invalid;
18412 }
18413
18414
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 792649 times.
795782 if (should_skip)
18415 3133 continue;
18416
18417 792649 memcpy(&colordata[q*48], temp_colordata, 48);
18418
18419 792649 ++q;
18420
7/8
✓ Branch 0 taken 792649 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60973 times.
✓ Branch 3 taken 731676 times.
✓ Branch 4 taken 506 times.
✓ Branch 5 taken 60467 times.
✓ Branch 6 taken 378 times.
✓ Branch 7 taken 128 times.
792649 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18421 {
18422
1/2
✓ Branch 0 taken 60845 times.
✗ Branch 1 not taken.
60845 if (s_version < 5) //Bumping up the size of level palettes
18423 {
18424 60845 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18425 60845 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18426 60845 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18427 60845 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18428 60845 q+=4;
18429 60845 }
18430 else
18431 {
18432 for(int m = 0; m < 4; ++m)
18433 {
18434 memset(temp_colordata, 0, 48);
18435 if(!pfread(temp_colordata,48,f))
18436 {
18437 return qe_invalid;
18438 }
18439 memcpy(&colordata[q*48], temp_colordata, 48);
18440 ++q;
18441 }
18442 }
18443 60845 }
18444 792649 ++p;
18445 792649 }
18446
18447
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 189 times.
254 if(s_version < 4)
18448 {
18449
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 64 times.
65 if (!should_skip)
18450 {
18451 64 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18452 64 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18453 64 }
18454 65 }
18455 else
18456 {
18457
2/2
✓ Branch 0 taken 628992 times.
✓ Branch 1 taken 189 times.
629181 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18458 {
18459
1/2
✓ Branch 0 taken 628992 times.
✗ Branch 1 not taken.
628992 if(!pfread(temp_colordata,48,f))
18460 {
18461 return qe_invalid;
18462 }
18463
18464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 628992 times.
628992 if (should_skip)
18465 continue;
18466
18467 628992 memcpy(&colordata[q*48], temp_colordata, 48);
18468 628992 ++q;
18469
5/6
✓ Branch 0 taken 628992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48384 times.
✓ Branch 3 taken 580608 times.
✓ Branch 4 taken 378 times.
✓ Branch 5 taken 48006 times.
628992 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18470 {
18471
1/2
✓ Branch 0 taken 48006 times.
✗ Branch 1 not taken.
48006 if (s_version < 5) //Bumping up the size of level palettes
18472 {
18473 48006 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18474 48006 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18475 48006 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18476 48006 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18477 48006 q+=4;
18478 48006 }
18479 else
18480 {
18481 for(int m = 0; m < 4; ++m)
18482 {
18483 memset(temp_colordata, 0, 48);
18484 if(!pfread(temp_colordata,48,f))
18485 {
18486 return qe_invalid;
18487 }
18488 memcpy(&colordata[q*48], temp_colordata, 48);
18489 ++q;
18490 }
18491 }
18492 48006 }
18493 628992 ++p;
18494 628992 }
18495
18496 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18497 }
18498 }
18499 272 }
18500 else
18501 {
18502
2/2
✓ Branch 0 taken 3683329 times.
✓ Branch 1 taken 421 times.
3683750 for(int32_t i=0; i<pdTOTAL255; ++i)
18503 {
18504 3683329 memset(temp_colordata, 0, 48);
18505
18506
1/2
✓ Branch 0 taken 3683329 times.
✗ Branch 1 not taken.
3683329 if(!pfread(temp_colordata,48,f))
18507 {
18508 return qe_invalid;
18509 }
18510
18511 3683329 memcpy(&colordata[i*48], temp_colordata, 48);
18512 3683329 }
18513 }
18514
18515
4/4
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 654 times.
693 if (!should_skip && s_version < 6)
18516 {
18517
2/2
✓ Branch 0 taken 274648608 times.
✓ Branch 1 taken 654 times.
274649262 for (int i = 0; i < psTOTAL255; i++)
18518 {
18519 274648608 colordata[i] = _rgb_scale_6[colordata[i]];
18520 274648608 }
18521 654 }
18522
18523
5/6
✓ Branch 0 taken 675 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 669 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
693 if((version < 0x192)||((version == 0x192)&&(build<76)))
18524 {
18525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
18526 18 init_palnames();
18527 18 }
18528 else
18529 {
18530 675 int32_t palnamestoread = 0;
18531
18532
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 610 times.
675 if(s_version < 3)
18533 65 palnamestoread = OLDMAXLEVELS;
18534 else
18535 610 palnamestoread = 512;
18536
18537
2/2
✓ Branch 0 taken 328960 times.
✓ Branch 1 taken 675 times.
329635 for(int32_t i=0; i<palnamestoread; ++i)
18538 {
18539
1/2
✓ Branch 0 taken 328960 times.
✗ Branch 1 not taken.
328960 if(!p_getstr(temp_palname,PALNAMESIZE,f))
18540 {
18541 return qe_invalid;
18542 }
18543
18544
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 328704 times.
328960 if (!should_skip)
18545 328704 memcpy(palnames[i], temp_palname, PALNAMESIZE);
18546 328960 }
18547
18548
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 674 times.
675 if (should_skip)
18549 1 return 0;
18550
18551
2/2
✓ Branch 0 taken 16384 times.
✓ Branch 1 taken 674 times.
17058 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
18552 {
18553 16384 memset(palnames[i], 0, PALNAMESIZE);
18554 16384 }
18555 }
18556
18557
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 669 times.
692 if(version > 0x192)
18558 {
18559
2/2
✓ Branch 0 taken 171264 times.
✓ Branch 1 taken 669 times.
171933 for(int32_t i=0; i<256; i++)
18560 {
18561
2/2
✓ Branch 0 taken 513792 times.
✓ Branch 1 taken 171264 times.
685056 for(int32_t j=0; j<3; j++)
18562 {
18563 513792 temp_misc.cycles[i][j].first=0;
18564 513792 temp_misc.cycles[i][j].count=0;
18565 513792 temp_misc.cycles[i][j].speed=0;
18566 513792 }
18567 171264 }
18568
18569
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&palcycles,f))
18570 {
18571 return qe_invalid;
18572 }
18573
18574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
669 if (palcycles > NUM_PAL_CYCLES)
18575 {
18576 return qe_invalid;
18577 }
18578
18579
2/2
✓ Branch 0 taken 15342 times.
✓ Branch 1 taken 669 times.
16011 for(int32_t i=0; i<palcycles; i++)
18580 {
18581
2/2
✓ Branch 0 taken 46026 times.
✓ Branch 1 taken 15342 times.
61368 for(int32_t j=0; j<3; j++)
18582 {
18583
1/2
✓ Branch 0 taken 46026 times.
✗ Branch 1 not taken.
46026 if(!p_getc(&temp_misc.cycles[i][j].first,f))
18584 {
18585 return qe_invalid;
18586 }
18587 46026 }
18588
18589
2/2
✓ Branch 0 taken 46026 times.
✓ Branch 1 taken 15342 times.
61368 for(int32_t j=0; j<3; j++)
18590 {
18591
1/2
✓ Branch 0 taken 46026 times.
✗ Branch 1 not taken.
46026 if(!p_getc(&temp_misc.cycles[i][j].count,f))
18592 {
18593 return qe_invalid;
18594 }
18595 46026 }
18596
18597
2/2
✓ Branch 0 taken 46026 times.
✓ Branch 1 taken 15342 times.
61368 for(int32_t j=0; j<3; j++)
18598 {
18599
1/2
✓ Branch 0 taken 46026 times.
✗ Branch 1 not taken.
46026 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
18600 {
18601 return qe_invalid;
18602 }
18603 46026 }
18604 15342 }
18605
18606 669 memcpy(Misc, &temp_misc, sizeof(temp_misc));
18607 669 }
18608
18609 692 return 0;
18610 693 }
18611
18612 693 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init)
18613 {
18614
2/2
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 24 times.
693 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_tiles);
18615
18616 693 int32_t tiles_used=0;
18617 693 word section_version = 0;
18618 693 word section_cversion = 0;
18619 693 int32_t section_size= 0;
18620 693 byte *temp_tile = new byte[tilesize(tf32Bit)];
18621
18622 //Tile Expansion
18623 //if ( version >= 0x254 && build >= 41 )
18624
4/4
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 421 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 266 times.
693 if (version < 0x254 && build < 41)
18625 {
18626 266 max_tiles = ZC250MAXTILES;
18627 266 }
18628
18629
18630
2/6
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 693 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
693 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
18631 {
18632 if(!init_tiles(true, Header))
18633 {
18634 al_trace("Unable to initialize tiles\n");
18635 }
18636
18637 delete[] temp_tile;
18638 temp_tile=NULL;
18639 return 0;
18640 }
18641 else
18642 {
18643
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 669 times.
693 if(version > 0x192)
18644 {
18645 //section version info
18646
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&section_version,f))
18647 {
18648 delete[] temp_tile;
18649 return qe_invalid;
18650 }
18651
18652 669 FFCore.quest_format[vTiles] = section_version;
18653
18654
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&section_cversion,f))
18655 {
18656 delete[] temp_tile;
18657 return qe_invalid;
18658 }
18659
18660 //section size
18661
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetl(&section_size,f))
18662 {
18663 delete[] temp_tile;
18664 return qe_invalid;
18665 }
18666 669 }
18667
18668 //if ( build < 41 )
18669 //{
18670 // tiles_used = ZC250MAXTILES;
18671 //}
18672
18673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
693 if(version < 0x174)
18674 {
18675 tiles_used=TILES_PER_PAGE*4;
18676 } //no expanded tile space
18677
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 675 times.
693 else if(version < 0x191)
18678 {
18679 18 tiles_used=OLDMAXTILES;
18680 18 }
18681 else
18682 {
18683 //finally... section data
18684
3/4
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 254 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 421 times.
675 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
18685 {
18686
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 if(!p_igetl(&tiles_used,f))
18687 {
18688 delete[] temp_tile;
18689 return qe_invalid;
18690 }
18691 421 }
18692 else
18693 {
18694
1/2
✓ Branch 0 taken 254 times.
✗ Branch 1 not taken.
254 if(!p_igetw(&tiles_used,f))
18695 {
18696 delete[] temp_tile;
18697 return qe_invalid;
18698 }
18699 }
18700 }
18701
18702
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 tiles_used=zc_min(tiles_used, max_tiles);
18703
18704 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
18705 //if ( version < 0x254 && build < 41 )
18706
3/6
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 272 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 421 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
693 if ( version < 0x254 || (version == 0x254 && build < 41) )
18707 //if ( build < 41 )
18708 {
18709
1/2
✓ Branch 0 taken 272 times.
✗ Branch 1 not taken.
272 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
18710 272 }
18711 else //2.55
18712 {
18713
1/2
✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
421 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
18714 }
18715
18716 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
18717
18718
18719
2/2
✓ Branch 0 taken 28341989 times.
✓ Branch 1 taken 693 times.
28342682 for(int32_t i=0; i<tiles_used; ++i)
18720 {
18721 28341989 byte format=tf4Bit;
18722 28341989 memset(temp_tile, 0, tilesize(tf32Bit));
18723
18724
3/6
✓ Branch 0 taken 2985456 times.
✓ Branch 1 taken 25356533 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2985456 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
28341989 if((version>0x211)||((version==0x211)&&(build>4)))
18725 {
18726
1/2
✓ Branch 0 taken 25356533 times.
✗ Branch 1 not taken.
25356533 if(!p_getc(&format,f))
18727 {
18728 delete[] temp_tile;
18729 return qe_invalid;
18730 }
18731 25356533 }
18732
4/4
✓ Branch 0 taken 18139398 times.
✓ Branch 1 taken 10202591 times.
✓ Branch 2 taken 8284775 times.
✓ Branch 3 taken 9854623 times.
28341989 if(section_version > 2 && !format)
18733 {
18734 9854623 reset_tile(buf,start_tile+i,tf4Bit);
18735 9854623 continue;
18736 }
18737
18738
2/2
✓ Branch 0 taken 17974186 times.
✓ Branch 1 taken 513180 times.
18487366 int size = format == tf4Bit ? 128 : tilesize(format);
18739
1/2
✓ Branch 0 taken 18487366 times.
✗ Branch 1 not taken.
18487366 if(!pfread(temp_tile,size,f))
18740 {
18741 delete[] temp_tile;
18742 return qe_invalid;
18743 }
18744
18745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18487366 times.
18487366 if (should_skip)
18746 continue;
18747
18748 18487366 buf[start_tile+i].format=format;
18749
18750
2/2
✓ Branch 0 taken 18316222 times.
✓ Branch 1 taken 171144 times.
18487366 if(buf[start_tile+i].data)
18751 {
18752 18316222 free(buf[start_tile+i].data);
18753 18316222 buf[start_tile+i].data=NULL;
18754 18316222 }
18755
18756 18487366 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
18757
18758
2/2
✓ Branch 0 taken 17974186 times.
✓ Branch 1 taken 513180 times.
18487366 if (format == tf4Bit)
18759 {
18760 byte temp[256];
18761 17974186 byte *si = temp_tile + 128;
18762 17974186 byte *di = temp + 256;
18763
18764
2/2
✓ Branch 0 taken 2300695808 times.
✓ Branch 1 taken 17974186 times.
2318669994 for(int i=127; i>=0; --i)
18765 {
18766 2300695808 (*(--di)) = (*(--si)) >> 4;
18767 2300695808 (*(--di)) = (*si) & 15;
18768 2300695808 }
18769
18770 17974186 memcpy(buf[start_tile+i].data,temp,256);
18771 17974186 }
18772 else
18773 {
18774 513180 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
18775 }
18776 18487366 }
18777 }
18778
18779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
693 if (should_skip)
18780 return 0;
18781
18782
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 272 times.
693 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
18783 {
18784
2/2
✓ Branch 0 taken 40522560 times.
✓ Branch 1 taken 272 times.
40522832 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
18785 {
18786
18787 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
18788 40522560 reset_tile(buf,q,tf4Bit);
18789
18790
18791 /*
18792
18793 byte tempbyte;
18794 for(int32_t i=0; i<tilesize(tf4Bit); i++)
18795 {
18796 tempbyte=buf[ZC250MAXTILES-1].data[i];
18797 buf[q].data[i] = tempbyte;
18798 }
18799 //int32_t temp = tempbyte=buf[130].data[i];
18800 //buf[q].data = buf[ZC250MAXTILES-1].data;
18801 */
18802 //reset_tile(buf,q,tf4Bit);
18803 40522560 }
18804
18805 272 }
18806
18807
4/6
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 272 times.
✓ Branch 2 taken 421 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 421 times.
693 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
18808 {
18809
2/2
✓ Branch 0 taken 9086445 times.
✓ Branch 1 taken 272 times.
9086717 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
18810 {
18811 9086445 reset_tile(buf,i,tf4Bit);
18812 9086445 }
18813 272 }
18814 else
18815 {
18816
2/2
✓ Branch 0 taken 71591386 times.
✓ Branch 1 taken 421 times.
71591807 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
18817 {
18818 71591386 reset_tile(buf,i,tf4Bit);
18819 71591386 }
18820 }
18821
18822
5/6
✓ Branch 0 taken 675 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 669 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
693 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
18823 {
18824
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(get_qr(qr_BSZELDA)) //
18825 {
18826 byte tempbyte;
18827 6 int32_t floattile=wpnsbuf[iwSwim].tile;
18828
18829
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
18830 {
18831 1536 tempbyte=buf[23].data[i];
18832 1536 buf[23].data[i]=buf[24].data[i];
18833 1536 buf[24].data[i]=buf[25].data[i];
18834 1536 buf[25].data[i]=buf[26].data[i];
18835 1536 buf[26].data[i]=tempbyte;
18836 1536 }
18837 //swim tiles are out of order, too, but nobody cared? -Z
18838
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++)
18839 {
18840 1536 tempbyte=buf[floattile+11].data[i];
18841 1536 buf[floattile+11].data[i]=buf[floattile+12].data[i];
18842 1536 buf[floattile+12].data[i]=tempbyte;
18843 1536 }
18844 6 }
18845 24 }
18846
18847
3/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 83 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 610 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
693 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
18848 {
18849
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 22 times.
83 if(!get_qr(qr_NEWENEMYTILES))
18850 {
18851 byte tempbyte;
18852
18853
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<tilesize(tf4Bit); i++)
18854 {
18855 5632 tempbyte=buf[130].data[i];
18856 5632 buf[130].data[i]=buf[132].data[i];
18857 5632 buf[132].data[i]=tempbyte;
18858
18859 5632 tempbyte=buf[131].data[i];
18860 5632 buf[131].data[i]=buf[133].data[i];
18861 5632 buf[133].data[i]=tempbyte;
18862 5632 }
18863 22 }
18864 83 }
18865
18866 693 al_trace("Registering blank tiles\n");
18867 693 register_blank_tiles();
18868
18869 //memset(temp_tile, 0, tilesize(tf32Bit));
18870
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 delete[] temp_tile;
18871 693 temp_tile=NULL;
18872 693 return 0;
18873 693 }
18874
18875 692 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/)
18876 {
18877
2/2
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 23 times.
692 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_midis);
18878
18879 static byte fake_midi_flags[32];
18880
18881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
692 byte *mf=should_skip ? fake_midi_flags : midi_flags;
18882 int32_t dummy;
18883 word dummy2;
18884 // zcmidi_ temp_midi;
18885 int32_t tunes_to_read;
18886 692 int32_t tune_count=0;
18887 692 word section_version=0;
18888 692 zctune temp;
18889
18890
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 669 times.
692 if(Header->zelda_version < 0x193)
18891 {
18892 // mf=Header->data_flags+ZQ_MIDIS2;
18893
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
23 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
18894 {
18895 22 tunes_to_read=MAXCUSTOMMIDIS192b177;
18896 22 }
18897 else
18898 {
18899 1 tunes_to_read=MAXCUSTOMTUNES;
18900 }
18901 23 }
18902 else
18903 {
18904 //section version info
18905
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&section_version,f))
18906 {
18907 return qe_invalid;
18908 }
18909
18910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
669 if (!should_skip)
18911 669 FFCore.quest_format[vMIDIs] = section_version;
18912
18913
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&dummy2,f))
18914 {
18915 return qe_invalid;
18916 }
18917
18918 //section size
18919
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetl(&dummy,f))
18920 {
18921 return qe_invalid;
18922 }
18923
18924 //finally... section data
18925
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!pfread(midi_flags,sizeof(midi_flags),f))
18926 {
18927 return qe_invalid;
18928 }
18929
18930 669 tunes_to_read=MAXCUSTOMTUNES;
18931 }
18932
18933
2/2
✓ Branch 0 taken 174384 times.
✓ Branch 1 taken 692 times.
175076 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
18934 {
18935
2/2
✓ Branch 0 taken 10241 times.
✓ Branch 1 taken 164143 times.
174384 if(get_bit(mf, i))
18936 {
18937 10241 ++tune_count;
18938 10241 }
18939 174384 }
18940
18941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
692 if (!should_skip)
18942 692 reset_tunes(tunes); //reset_midis(midis);
18943
18944
2/2
✓ Branch 0 taken 169544 times.
✓ Branch 1 taken 692 times.
170236 for(int32_t i=0; i<tunes_to_read; i++)
18945 {
18946 169544 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
18947
18948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 169544 times.
169544 if (!should_skip)
18949 169544 tunes[i].reset(); // reset_midi(midis+i);
18950
18951
2/2
✓ Branch 0 taken 159303 times.
✓ Branch 1 taken 10241 times.
169544 if(get_bit(mf,i))
18952 {
18953
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7578 times.
10241 if(section_version < 4)
18954 {
18955
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if(!p_getstr(temp.title,20,f))
18956 {
18957 return qe_invalid;
18958 }
18959 2663 }
18960 else
18961 {
18962
1/2
✓ Branch 0 taken 7578 times.
✗ Branch 1 not taken.
7578 if(!p_getstr(temp.title,sizeof(temp.title)-1,f))
18963 {
18964 return qe_invalid;
18965 }
18966 }
18967
18968
1/2
✓ Branch 0 taken 10241 times.
✗ Branch 1 not taken.
10241 if(!p_igetl(&temp.start,f))
18969 {
18970 return qe_invalid;
18971 }
18972
18973
1/2
✓ Branch 0 taken 10241 times.
✗ Branch 1 not taken.
10241 if(!p_igetl(&temp.loop_start,f))
18974 {
18975 return qe_invalid;
18976 }
18977
18978
1/2
✓ Branch 0 taken 10241 times.
✗ Branch 1 not taken.
10241 if(!p_igetl(&temp.loop_end,f))
18979 {
18980 return qe_invalid;
18981 }
18982
18983
1/2
✓ Branch 0 taken 10241 times.
✗ Branch 1 not taken.
10241 if(!p_igetw(&temp.loop,f))
18984 {
18985 return qe_invalid;
18986 }
18987
18988
1/2
✓ Branch 0 taken 10241 times.
✗ Branch 1 not taken.
10241 if(!p_igetw(&temp.volume,f))
18989 {
18990 return qe_invalid;
18991 }
18992
18993
2/2
✓ Branch 0 taken 9992 times.
✓ Branch 1 taken 249 times.
10241 if(Header->zelda_version < 0x193)
18994 {
18995
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(!p_igetl(&dummy,f))
18996 {
18997 return qe_invalid;
18998 }
18999 249 }
19000
19001
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7578 times.
10241 if(section_version >= 3)
19002 {
19003
1/2
✓ Branch 0 taken 7578 times.
✗ Branch 1 not taken.
7578 if(!pfread(&temp.flags,sizeof(temp.flags),f))
19004 {
19005 return qe_invalid;
19006 }
19007 7578 }
19008
19009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10241 times.
10241 if (!should_skip)
19010 10241 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19011
19012
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7578 times.
10241 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19013 {
19014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2663 times.
2663 if (should_skip)
19015 {
19016 if (read_midi(f)==NULL)
19017 {
19018 return qe_invalid;
19019 }
19020
19021 continue;
19022 }
19023
19024 // old format - a midi is a midi
19025
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if((tunes[i].data=read_midi(f))==NULL)
19026 {
19027 return qe_invalid;
19028 }
19029
19030 //yes you can do this. Isn't the ? operator awesome? :)
19031 2663 tunes[i].format = MFORMAT_MIDI;
19032 2663 }
19033 else
19034 {
19035 // 'midi' could be midi or nes, gb, ... music
19036
1/2
✓ Branch 0 taken 7578 times.
✗ Branch 1 not taken.
7578 if(!pfread(&tunes[i].format,sizeof(tunes[i].format),f))
19037 {
19038 return qe_invalid;
19039 }
19040
19041 7578 zctune *ptr = &tunes[i];
19042
19043
1/2
✓ Branch 0 taken 7578 times.
✗ Branch 1 not taken.
7578 switch(temp.format)
19044 {
19045 case MFORMAT_MIDI:
19046
1/2
✓ Branch 0 taken 7578 times.
✗ Branch 1 not taken.
7578 if((ptr->data=read_midi(f))==NULL)
19047 {
19048 return qe_invalid;
19049 }
19050
19051 7578 break;
19052
19053 default:
19054 return qe_invalid;
19055 break;
19056 }
19057 }
19058 10241 }
19059 169544 }
19060
19061 692 return 0;
19062 692 }
19063
19064 692 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header)
19065 {
19066
2/2
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 23 times.
692 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_cheats);
19067
19068 int32_t dummy;
19069 ZCHEATS tempzcheats;
19070 692 char temp_use_cheats=1;
19071 692 memset(&tempzcheats, 0, sizeof(tempzcheats));
19072 692 word s_version = 0;
19073
19074
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 669 times.
692 if(Header->zelda_version > 0x192)
19075 {
19076 //section version info
19077
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&s_version,f))
19078 {
19079 return qe_invalid;
19080 }
19081
19082 669 FFCore.quest_format[vCheats] = s_version;
19083
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetw(&dummy,f))
19084 {
19085 return qe_invalid;
19086 }
19087
19088 //section size
19089
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_igetl(&dummy,f))
19090 {
19091 return qe_invalid;
19092 }
19093
19094 //finally... section data
19095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
669 if(!p_getc(&temp_use_cheats,f))
19096 {
19097 return qe_invalid;
19098 }
19099 669 }
19100
19101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
692 if(Header->data_flags[ZQ_CHEATS2])
19102 {
19103
1/2
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
692 if(!p_igetl(&tempzcheats.flags,f))
19104 {
19105 return qe_invalid;
19106 }
19107
19108
1/2
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
692 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes),f))
19109 {
19110 return qe_invalid;
19111 }
19112 692 }
19113
19114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
692 if (should_skip)
19115 return 0;
19116
19117 692 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19118 692 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19119
19120 692 return 0;
19121 692 }
19122
19123 289 int32_t readinitdata_old(PACKFILE *f, zquestheader *Header, word s_version, word s_cversion, zinitdata& temp_zinit)
19124 {
19125
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 266 times.
289 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
19126
19127 int32_t dummy;
19128 byte padding, tempbyte;
19129
19130 // Legacy item properties (now integrated into itemdata)
19131 byte sword_hearts[4];
19132 byte beam_hearts[4];
19133 289 byte beam_percent=0;
19134 word beam_power[4];
19135 289 byte hookshot_length=99;
19136 289 byte hookshot_links=100;
19137 289 byte longshot_length=99;
19138 289 byte longshot_links=100;
19139 289 byte moving_fairy_hearts=3;
19140 289 byte moving_fairy_heart_percent=0;
19141 289 byte stationary_fairy_hearts=3;
19142 289 byte stationary_fairy_heart_percent=0;
19143 289 byte moving_fairy_magic=0;
19144 289 byte moving_fairy_magic_percent=0;
19145 289 byte stationary_fairy_magic=0;
19146 289 byte stationary_fairy_magic_percent=0;
19147 289 byte blue_potion_hearts=100;
19148 289 byte blue_potion_heart_percent=1;
19149 289 byte red_potion_hearts=100;
19150 289 byte red_potion_heart_percent=1;
19151 289 byte blue_potion_magic=100;
19152 289 byte blue_potion_magic_percent=1;
19153 289 byte red_potion_magic=100;
19154 289 byte red_potion_magic_percent=1;
19155
19156 289 byte bomb_ratio = 4;
19157
19158 289 subscr_mode = 0;
19159
19160 /* HIGHLY UNORTHODOX UPDATING THING, by L
19161 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19162 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19163 * changing from 13 to 14.
19164 */
19165
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 82 times.
289 if(s_version < 14)
19166 82 fixpolsvoice=true;
19167
19168 /* End highly unorthodox updating thing */
19169
19170
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 95 times.
✓ Branch 3 taken 112 times.
289 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19171 112 temp_zinit.jump_hero_layer_threshold=0;
19172
19173
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 207 times.
289 if(s_version >= 10)
19174 {
19175 char temp;
19176
19177 //new-style items
19178
2/2
✓ Branch 0 taken 52992 times.
✓ Branch 1 taken 207 times.
53199 for(int32_t j=0; j<256; j++)
19179 {
19180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52992 times.
52992 if(!p_getc(&temp,f))
19181 return qe_invalid;
19182
19183 52992 temp_zinit.set_item(j, temp != 0);
19184 52992 }
19185 207 }
19186
19187
5/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 266 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
289 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19188 {
19189 char temp;
19190
19191 //finally... section data
19192
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 266 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
276 if((Header->zelda_version > 0x192)||
19193 //new only
19194
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19195 {
19196 //OLD-style items... sigh
19197
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 60 times.
267 if(s_version < 10)
19198 {
19199
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19200 {
19201 return qe_invalid;
19202 }
19203
19204 60 temp_zinit.set_item(iRaft, temp != 0);
19205
19206
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19207 {
19208 return qe_invalid;
19209 }
19210
19211 60 temp_zinit.set_item(iLadder, temp != 0);
19212
19213
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19214 {
19215 return qe_invalid;
19216 }
19217
19218 60 temp_zinit.set_item(iBook, temp != 0);
19219
19220
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19221 {
19222 return qe_invalid;
19223 }
19224
19225 60 temp_zinit.set_item(iMKey, temp != 0);
19226
19227
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19228 {
19229 return qe_invalid;
19230 }
19231
19232 60 temp_zinit.set_item(iFlippers, temp != 0);
19233
19234
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19235 {
19236 return qe_invalid;
19237 }
19238
19239 60 temp_zinit.set_item(iBoots, temp != 0);
19240 60 }
19241 267 }
19242
19243
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 64 times.
271 if(s_version < 10)
19244 {
19245 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19246
19247
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempring,f))
19248 {
19249 return qe_invalid;
19250 }
19251
19252
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempsword,f))
19253 {
19254 return qe_invalid;
19255 }
19256
19257
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempshield,f))
19258 {
19259 return qe_invalid;
19260 }
19261
19262
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwallet,f))
19263 {
19264 return qe_invalid;
19265 }
19266
19267
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbracelet,f))
19268 {
19269 return qe_invalid;
19270 }
19271
19272
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempamulet,f))
19273 {
19274 return qe_invalid;
19275 }
19276
19277
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbow,f))
19278 {
19279 return qe_invalid;
19280 }
19281
19282 //old only
19283
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
19284 {
19285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempring=(tempring)?(1<<(tempring-1)):0;
19286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19287
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19292 4 }
19293
19294 //rings start at level 2... wtf
19295 //account for this -DD
19296 64 tempring <<= 1;
19297 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19298 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19299 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19300 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19301 //bracelet ALSO starts at level 2 :-( -DD
19302 64 tempbracelet<<=1;
19303 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19304 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19305 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19306
19307 //new only
19308
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
64 if((Header->zelda_version == 0x192)&&(Header->build>173))
19309 {
19310
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
19311 {
19312
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
19313 {
19314 return qe_invalid;
19315 }
19316 32 }
19317 1 }
19318
19319 char tempcandle, tempboomerang, temparrow, tempwhistle;
19320
19321
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempcandle,f))
19322 {
19323 return qe_invalid;
19324 }
19325
19326
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempboomerang,f))
19327 {
19328 return qe_invalid;
19329 }
19330
19331
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temparrow,f))
19332 {
19333 return qe_invalid;
19334 }
19335
19336
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temp,f))
19337 {
19338 return qe_invalid;
19339 }
19340
19341 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19342
19343
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwhistle,f))
19344 {
19345 return qe_invalid;
19346 }
19347
19348 //old only
19349
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
19350 {
19351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19355 4 }
19356
19357 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19358 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19359 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19360 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19361 //What about the potion...?
19362
19363 64 }
19364
19365
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 253 times.
271 if(s_version < 29)
19366 {
19367 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19368 //to jab out my eye...
19369
1/2
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
253 if(!p_getc(&padding,f))
19370 return qe_invalid;
19371 253 temp_zinit.counter[crBOMBS] = padding;
19372
19373
1/2
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
253 if(!p_getc(&padding,f))
19374 return qe_invalid;
19375 253 temp_zinit.counter[crSBOMBS] = padding;
19376 253 }
19377
19378 //Back to more OLD item code
19379
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 64 times.
271 if(s_version < 10)
19380 {
19381
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
69 if((Header->zelda_version > 0x192)||
19382 //new only
19383
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19384 {
19385
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19386 {
19387 return qe_invalid;
19388 }
19389
19390 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19391
19392
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19393 {
19394 return qe_invalid;
19395 }
19396
19397 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19398
19399
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19400 {
19401 return qe_invalid;
19402 }
19403
19404 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19405
19406
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19407 {
19408 return qe_invalid;
19409 }
19410
19411 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19412
19413
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19414 {
19415 return qe_invalid;
19416 }
19417
19418 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19419
19420
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19421 {
19422 return qe_invalid;
19423 }
19424
19425 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19426
19427
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19428 {
19429 return qe_invalid;
19430 }
19431
19432 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19433
19434
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19435 {
19436 return qe_invalid;
19437 }
19438
19439 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19440
19441
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19442 {
19443 return qe_invalid;
19444 }
19445
19446 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
19447
19448
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19449 {
19450 return qe_invalid;
19451 }
19452
19453
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1 times.
60 if(Header->zelda_version == 0x192)
19454 {
19455
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
19456 {
19457
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
19458 {
19459 return qe_invalid;
19460 }
19461 32 }
19462 1 }
19463 60 }
19464 64 }
19465
19466 //old only
19467
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 266 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
271 if((Header->zelda_version == 0x192)&&(Header->build<174))
19468 {
19469 byte equipment, tmpitm; //bit flags
19470
19471
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&equipment,f))
19472 {
19473 return qe_invalid;
19474 }
19475
19476 4 temp_zinit.set_item(iRaft, get_bit(&equipment, idE_RAFT)!=0);
19477 4 temp_zinit.set_item(iLadder, get_bit(&equipment, idE_LADDER)!=0);
19478 4 temp_zinit.set_item(iBook, get_bit(&equipment, idE_BOOK)!=0);
19479 4 temp_zinit.set_item(iMKey, get_bit(&equipment, idE_KEY)!=0);
19480 4 temp_zinit.set_item(iFlippers, get_bit(&equipment, idE_FLIPPERS)!=0);
19481 4 temp_zinit.set_item(iBoots, get_bit(&equipment, idE_BOOTS)!=0);
19482
19483
19484
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tmpitm,f))
19485 {
19486 return qe_invalid;
19487 }
19488
19489 4 temp_zinit.set_item(iWand, get_bit(&tmpitm, idI_WAND)!=0);
19490 4 temp_zinit.set_item(iLetter, get_bit(&tmpitm, idI_LETTER)!=0);
19491 4 temp_zinit.set_item(iLens, get_bit(&tmpitm, idI_LENS)!=0);
19492 4 temp_zinit.set_item(iHookshot, get_bit(&tmpitm, idI_HOOKSHOT)!=0);
19493 4 temp_zinit.set_item(iBait, get_bit(&tmpitm, idI_BAIT)!=0);
19494 4 temp_zinit.set_item(iHammer, get_bit(&tmpitm, idI_HAMMER)!=0);
19495 4 }
19496
19497
1/2
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
271 if(!p_getc(&tempbyte,f))
19498 return qe_invalid;
19499 271 temp_zinit.mcounter[crLIFE] = tempbyte;
19500
19501
19502
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 207 times.
271 if(s_version < 14)
19503 {
19504 byte temphp;
19505
19506
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
19507 {
19508 return qe_invalid;
19509 }
19510
19511 64 temp_zinit.counter[crLIFE]=temphp;
19512
19513
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
19514 {
19515 return qe_invalid;
19516 }
19517
19518 64 temp_zinit.cont_heart=temphp;
19519 64 }
19520 else
19521 {
19522
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.counter[crLIFE],f))
19523 {
19524 return qe_invalid;
19525 }
19526
19527
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.cont_heart,f))
19528 {
19529 return qe_invalid;
19530 }
19531 }
19532
19533
1/2
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
271 if(!p_getc(&temp_zinit.hcp,f))
19534 {
19535 return qe_invalid;
19536 }
19537
19538
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 207 times.
271 if(s_version >= 14)
19539 {
19540
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_getc(&temp_zinit.hcp_per_hc,f))
19541 {
19542 return qe_invalid;
19543 }
19544
19545
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(s_version<16) // July 2007
19546 {
19547 if(get_qr(qr_BRANGPICKUP+1))
19548 temp_zinit.hcp_per_hc = 0xFF;
19549
19550 //Dispose of legacy rule
19551 set_qr(qr_BRANGPICKUP+1, 0);
19552 }
19553 207 }
19554
19555
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 253 times.
271 if(s_version < 29)
19556 {
19557
1/2
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
253 if(!p_getc(&padding,f))
19558 return qe_invalid;
19559 253 temp_zinit.mcounter[crBOMBS] = padding;
19560 253 }
19561
19562
1/2
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
271 if(!p_getc(&temp_zinit.counter[crKEYS],f))
19563 {
19564 return qe_invalid;
19565 }
19566
19567
1/2
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
271 if(!p_igetw(&temp_zinit.counter[crMONEY],f))
19568 {
19569 return qe_invalid;
19570 }
19571
19572
1/2
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
271 if(!p_getc(&tempbyte,f))
19573 return qe_invalid;
19574
2/2
✓ Branch 0 taken 2168 times.
✓ Branch 1 taken 271 times.
2439 for(int q = 0; q < 8; ++q)
19575 2168 set_bit(temp_zinit.mcguffin, q+1, get_bitl(tempbyte, q));
19576
19577
3/6
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 207 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
271 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19578 {
19579
2/2
✓ Branch 0 taken 13248 times.
✓ Branch 1 taken 207 times.
13455 for(int32_t i=0; i<64; i++)
19580 {
19581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13248 times.
13248 if(!p_getc(&temp_zinit.map[i],f))
19582 {
19583 return qe_invalid;
19584 }
19585 13248 }
19586
19587
2/2
✓ Branch 0 taken 13248 times.
✓ Branch 1 taken 207 times.
13455 for(int32_t i=0; i<64; i++)
19588 {
19589
1/2
✓ Branch 0 taken 13248 times.
✗ Branch 1 not taken.
13248 if(!p_getc(&temp_zinit.compass[i],f))
19590 {
19591 return qe_invalid;
19592 }
19593 13248 }
19594 207 }
19595 else
19596 {
19597
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 64 times.
2112 for(int32_t i=0; i<32; i++)
19598 {
19599
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 if(!p_getc(&temp_zinit.map[i],f))
19600 {
19601 return qe_invalid;
19602 }
19603 2048 }
19604
19605
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 64 times.
2112 for(int32_t i=0; i<32; i++)
19606 {
19607
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 if(!p_getc(&temp_zinit.compass[i],f))
19608 {
19609 return qe_invalid;
19610 }
19611 2048 }
19612 }
19613
19614
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 266 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
276 if((Header->zelda_version > 0x192)||
19615 //new only
19616
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19617 {
19618
3/6
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 207 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 60 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
267 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19619 {
19620
2/2
✓ Branch 0 taken 13248 times.
✓ Branch 1 taken 207 times.
13455 for(int32_t i=0; i<64; i++)
19621 {
19622
1/2
✓ Branch 0 taken 13248 times.
✗ Branch 1 not taken.
13248 if(!p_getc(&temp_zinit.boss_key[i],f))
19623 {
19624 return qe_invalid;
19625 }
19626 13248 }
19627 207 }
19628 else
19629 {
19630
2/2
✓ Branch 0 taken 1920 times.
✓ Branch 1 taken 60 times.
1980 for(int32_t i=0; i<32; i++)
19631 {
19632
1/2
✓ Branch 0 taken 1920 times.
✗ Branch 1 not taken.
1920 if(!p_getc(&temp_zinit.boss_key[i],f))
19633 {
19634 return qe_invalid;
19635 }
19636 1920 }
19637 }
19638 267 }
19639
19640 byte tmpmisc[16];
19641
2/2
✓ Branch 0 taken 4336 times.
✓ Branch 1 taken 271 times.
4607 for(int32_t i=0; i<16; i++)
19642
1/2
✓ Branch 0 taken 4336 times.
✗ Branch 1 not taken.
4336 if(!p_getc(&tmpmisc[i],f))
19643 return qe_invalid;
19644 271 temp_zinit.flags.set(INIT_FL_CONTPERCENT,get_bit(tmpmisc,0));
19645 271 temp_zinit.magicdrainrate = get_bit(tmpmisc,1) ? 1 : 2; //Double Magic flag
19646 271 temp_zinit.flags.set(INIT_FL_CANSLASH,get_bit(tmpmisc,2));
19647
19648
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 64 times.
527 if(s_version < 15) for(int32_t i=0; i<4; i++)
19649
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&sword_hearts[i],f))
19650 64 return qe_invalid;
19651
19652
1/2
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
271 if(!p_getc(&temp_zinit.last_map,f))
19653 {
19654 return qe_invalid;
19655 }
19656
19657
1/2
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
271 if(!p_getc(&temp_zinit.last_screen,f))
19658 {
19659 return qe_invalid;
19660 }
19661
19662
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 207 times.
271 if(s_version < 14)
19663 {
19664 byte tempmp;
19665
19666
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
19667 {
19668 return qe_invalid;
19669 }
19670
19671 64 temp_zinit.mcounter[crMAGIC]=tempmp;
19672
19673
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
19674 {
19675 return qe_invalid;
19676 }
19677
19678 64 temp_zinit.counter[crMAGIC]=tempmp;
19679 64 }
19680 else
19681 {
19682
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.mcounter[crMAGIC],f))
19683 {
19684 return qe_invalid;
19685 }
19686
19687
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.counter[crMAGIC],f))
19688 {
19689 return qe_invalid;
19690 }
19691 }
19692
19693
19694
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 207 times.
271 if(s_version < 15)
19695 {
19696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(s_version < 12)
19697 {
19698 64 temp_zinit.mcounter[crMAGIC]*=32;
19699 64 temp_zinit.counter[crMAGIC]*=32;
19700 64 }
19701
19702
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
19703 {
19704
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&beam_hearts[i],f))
19705 {
19706 return qe_invalid;
19707 }
19708 256 }
19709
19710
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&beam_percent,f))
19711 {
19712 return qe_invalid;
19713 }
19714 64 }
19715 else
19716 {
19717
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_getc(&temp_zinit.bomb_ratio,f))
19718 return qe_invalid;
19719
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(temp_zinit.bomb_ratio < 1)
19720 temp_zinit.bomb_ratio = 1;
19721 207 else bomb_ratio = temp_zinit.bomb_ratio; //jank
19722 }
19723
19724
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 64 times.
271 if(s_version < 15)
19725 {
19726 byte tempbp;
19727
19728
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
19729 {
19730
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
256 if(!(s_version < 14 ? p_getc(&tempbp,f) : p_igetw(&tempbp,f)))
19731 {
19732 return qe_invalid;
19733 }
19734
19735 256 beam_power[i]=tempbp;
19736 256 }
19737
19738
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&hookshot_links,f))
19739 {
19740 return qe_invalid;
19741 }
19742
19743
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(s_version>6)
19744 {
19745 if(!p_getc(&hookshot_length,f))
19746 {
19747 return qe_invalid;
19748 }
19749
19750 if(!p_getc(&longshot_links,f))
19751 {
19752 return qe_invalid;
19753 }
19754
19755 if(!p_getc(&longshot_length,f))
19756 {
19757 return qe_invalid;
19758 }
19759 }
19760 64 }
19761
19762
1/2
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
271 if(!p_getc(&temp_zinit.msg_more_x,f))
19763 {
19764 return qe_invalid;
19765 }
19766
19767
1/2
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
271 if(!p_getc(&temp_zinit.msg_more_y,f))
19768 {
19769 return qe_invalid;
19770 }
19771
19772
1/2
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
271 if(!p_getc(&subscr_mode,f))
19773 return qe_invalid;
19774
19775 //old only
19776
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 266 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
271 if((Header->zelda_version == 0x192)&&(Header->build<174))
19777 {
19778
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 4 times.
132 for(int32_t i=0; i<32; i++)
19779 {
19780
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&temp_zinit.boss_key[i],f))
19781 {
19782 return qe_invalid;
19783 }
19784 128 }
19785 4 }
19786
19787
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 266 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 4 times.
271 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
19788 {
19789
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 207 times.
267 if(s_version <= 10)
19790 {
19791
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&tempbyte,f))
19792 {
19793 return qe_invalid;
19794 }
19795
19796 60 temp_zinit.start_dmap = (word)tempbyte;
19797 60 }
19798 else
19799 {
19800
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.start_dmap,f))
19801 {
19802 return qe_invalid;
19803 }
19804 }
19805
19806
1/2
✓ Branch 0 taken 267 times.
✗ Branch 1 not taken.
267 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
19807 {
19808 return qe_invalid;
19809 }
19810 267 }
19811
19812
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 189 times.
271 if(s_version>1 && s_version < 29)
19813 {
19814
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(!p_getc(&padding,f))
19815 return qe_invalid;
19816 189 temp_zinit.counter[crARROWS] = padding;
19817
19818
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(!p_getc(&padding,f))
19819 return qe_invalid;
19820 189 temp_zinit.mcounter[crARROWS] = padding;
19821 189 }
19822
19823
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 207 times.
271 if(s_version>2)
19824 {
19825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 207 times.
207 if(s_version <= 10)
19826 {
19827 for(int32_t i=0; i<OLDMAXLEVELS; i++)
19828 {
19829 if(!p_getc(&(temp_zinit.level_keys[i]),f))
19830 {
19831 return qe_invalid;
19832 }
19833 }
19834 }
19835 else
19836 {
19837
2/2
✓ Branch 0 taken 105984 times.
✓ Branch 1 taken 207 times.
106191 for(int32_t i=0; i<MAXLEVELS; i++)
19838 {
19839
1/2
✓ Branch 0 taken 105984 times.
✗ Branch 1 not taken.
105984 if(!p_getc(&(temp_zinit.level_keys[i]),f))
19840 {
19841 return qe_invalid;
19842 }
19843 105984 }
19844 }
19845 207 }
19846
19847
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 207 times.
271 if(s_version>3)
19848 {
19849
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.ss_grid_x,f))
19850 {
19851 return qe_invalid;
19852 }
19853
19854
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.ss_grid_y,f))
19855 {
19856 return qe_invalid;
19857 }
19858
19859
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.ss_grid_xofs,f))
19860 {
19861 return qe_invalid;
19862 }
19863
19864
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.ss_grid_yofs,f))
19865 {
19866 return qe_invalid;
19867 }
19868
19869
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.ss_grid_color,f))
19870 {
19871 return qe_invalid;
19872 }
19873
19874
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f))
19875 {
19876 return qe_invalid;
19877 }
19878
19879
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f))
19880 {
19881 return qe_invalid;
19882 }
19883
19884
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.ss_flags,f))
19885 {
19886 return qe_invalid;
19887 }
19888
19889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 207 times.
207 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
19890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 207 times.
207 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
19891 207 }
19892
19893
3/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 207 times.
✗ Branch 3 not taken.
271 if(s_version>4 && s_version<15)
19894 {
19895 if(!p_getc(&moving_fairy_hearts,f))
19896 {
19897 return qe_invalid;
19898 }
19899
19900 if(!p_getc(&moving_fairy_heart_percent,f))
19901 {
19902 return qe_invalid;
19903 }
19904 }
19905
19906
3/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 207 times.
✗ Branch 3 not taken.
271 if(s_version>5 && s_version < 10)
19907 {
19908 if(!p_getc(&temp,f))
19909 {
19910 return qe_invalid;
19911 }
19912
19913 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
19914 }
19915
19916
3/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 207 times.
✗ Branch 3 not taken.
271 if(s_version>6 && s_version<15)
19917 {
19918 if(!p_getc(&stationary_fairy_hearts,f))
19919 {
19920 return qe_invalid;
19921 }
19922
19923 if(!p_getc(&stationary_fairy_heart_percent,f))
19924 {
19925 return qe_invalid;
19926 }
19927
19928 if(!p_getc(&moving_fairy_magic,f))
19929 {
19930 return qe_invalid;
19931 }
19932
19933 if(!p_getc(&moving_fairy_magic_percent,f))
19934 {
19935 return qe_invalid;
19936 }
19937
19938 if(!p_getc(&stationary_fairy_magic,f))
19939 {
19940 return qe_invalid;
19941 }
19942
19943 if(!p_getc(&stationary_fairy_magic_percent,f))
19944 {
19945 return qe_invalid;
19946 }
19947
19948 if(!p_getc(&blue_potion_hearts,f))
19949 {
19950 return qe_invalid;
19951 }
19952
19953 if(!p_getc(&blue_potion_heart_percent,f))
19954 {
19955 return qe_invalid;
19956 }
19957
19958 if(!p_getc(&red_potion_hearts,f))
19959 {
19960 return qe_invalid;
19961 }
19962
19963 if(!p_getc(&red_potion_heart_percent,f))
19964 {
19965 return qe_invalid;
19966 }
19967
19968 if(!p_getc(&blue_potion_magic,f))
19969 {
19970 return qe_invalid;
19971 }
19972
19973 if(!p_getc(&blue_potion_magic_percent,f))
19974 {
19975 return qe_invalid;
19976 }
19977
19978 if(!p_getc(&red_potion_magic,f))
19979 {
19980 return qe_invalid;
19981 }
19982
19983 if(!p_getc(&red_potion_magic_percent,f))
19984 {
19985 return qe_invalid;
19986 }
19987 }
19988
19989
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 207 times.
271 if(s_version>6)
19990
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_getc(&padding,f))
19991 return qe_invalid;
19992
19993
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 207 times.
271 if(s_version>7)
19994 {
19995
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_getc(&padding,f))
19996 {
19997 return qe_invalid;
19998 }
19999 207 }
20000
20001
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 207 times.
271 if(s_version>8)
20002 {
20003
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.mcounter[crMONEY],f))
20004 {
20005 return qe_invalid;
20006 }
20007
20008
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.mcounter[crKEYS],f))
20009 {
20010 return qe_invalid;
20011 }
20012 207 }
20013
20014
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 64 times.
271 if(s_version>16)
20015 {
20016
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_getc(&tempbyte,f))
20017 {
20018 return qe_invalid;
20019 }
20020 207 temp_zinit.gravity = tempbyte*100;
20021
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.terminalv,f))
20022 {
20023 return qe_invalid;
20024 }
20025
20026
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_getc(&temp_zinit.msg_speed,f))
20027 {
20028 return qe_invalid;
20029 }
20030
20031
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_getc(&padding,f))
20032 {
20033 return qe_invalid;
20034 }
20035
20036
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20037 {
20038 return qe_invalid;
20039 }
20040 207 }
20041
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 12 times.
64 else if (replay_version_check(0, 13))
20042 12 temp_zinit.msg_speed = 0;
20043
20044
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 207 times.
271 if(s_version>17)
20045 {
20046
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20047 {
20048 return qe_invalid;
20049 }
20050 207 }
20051
20052 //expaned init data for larger values in 2.55
20053
2/2
✓ Branch 0 taken 253 times.
✓ Branch 1 taken 18 times.
271 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20054 {
20055
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.counter[crBOMBS],f))
20056 {
20057 return qe_invalid;
20058 }
20059
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.counter[crSBOMBS],f))
20060 {
20061 return qe_invalid;
20062 }
20063
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.mcounter[crBOMBS],f))
20064 {
20065 return qe_invalid;
20066 }
20067
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.mcounter[crSBOMBS],f))
20068 {
20069 return qe_invalid;
20070 }
20071
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.counter[crARROWS],f))
20072 {
20073 return qe_invalid;
20074 }
20075
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.mcounter[crARROWS],f))
20076 {
20077 return qe_invalid;
20078 }
20079
20080 18 }
20081
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 253 times.
271 if ( s_version >= 20 )
20082 {
20083
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.heroStep,f))
20084 {
20085 return qe_invalid;
20086 }
20087 18 }
20088 else
20089 {
20090 253 temp_zinit.heroStep = 150; //1.5 pixels per frame
20091 }
20092
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 253 times.
271 if ( s_version >= 21 )
20093 {
20094
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20095 {
20096 return qe_invalid;
20097 }
20098 18 }
20099 else
20100 {
20101 253 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20102 }
20103 //old only
20104
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 266 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
271 if((Header->zelda_version == 0x192)&&(Header->build<174))
20105 {
20106 byte items2;
20107
20108
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&items2,f))
20109 {
20110 return qe_invalid;
20111 }
20112
20113 4 temp_zinit.set_item(iDivineFire, get_bit(&items2, idI_DFIRE)!=0);
20114 4 temp_zinit.set_item(iDivineEscape, get_bit(&items2, idI_FWIND)!=0);
20115 4 temp_zinit.set_item(iDivineProtection, get_bit(&items2, idI_NLOVE)!=0);
20116 4 }
20117
20118
2/2
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 5 times.
271 if(Header->zelda_version < 0x193)
20119 {
20120
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 5 times.
485 for(int32_t q=0; q<96; q++)
20121 {
20122
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(!p_getc(&padding,f))
20123 {
20124 return qe_invalid;
20125 }
20126 480 }
20127
20128 //new only
20129
3/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
5 if((Header->zelda_version == 0x192)&&(Header->build>173))
20130 {
20131
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20132 {
20133 return qe_invalid;
20134 }
20135
20136
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20137 {
20138 return qe_invalid;
20139 }
20140 1 }
20141 5 }
20142 271 }
20143
20144
3/6
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 207 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
289 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20145 {
20146 //temp_zinit.shield=i_smallshield;
20147 82 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20148
20149
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(sshieldid != -1)
20150 82 temp_zinit.set_item(sshieldid, true);
20151 82 }
20152
20153
5/6
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 266 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
289 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20154 {
20155 18 temp_zinit.mcounter[crLIFE]=3;
20156 18 temp_zinit.counter[crLIFE]=3;
20157 18 temp_zinit.cont_heart=3;
20158 18 temp_zinit.mcounter[crBOMBS]=8;
20159 18 }
20160
20161
5/6
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 266 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
289 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20162 {
20163 18 sword_hearts[0]=0;
20164 18 sword_hearts[1]=5;
20165 18 sword_hearts[2]=12;
20166 18 sword_hearts[3]=21;
20167 18 }
20168
20169
5/6
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 266 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
289 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20170 {
20171 18 temp_zinit.last_map=0;
20172 18 temp_zinit.last_screen=0;
20173 18 }
20174
20175
5/6
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 266 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
289 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20176 {
20177 18 temp_zinit.mcounter[crMAGIC]=0;
20178 18 temp_zinit.counter[crMAGIC]=0;
20179 18 temp_zinit.magicdrainrate = 2;
20180 18 }
20181
20182
5/6
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 266 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
289 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20183 {
20184
20185
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20186 {
20187 72 beam_hearts[x]=100;
20188 72 }
20189
20190
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t i=0; i<idBP_MAX; i++)
20191 {
20192 72 set_bit(&beam_percent,i,!get_qr(qr_LENSHINTS+i));
20193 72 set_qr(qr_LENSHINTS+i,0);
20194 72 }
20195
20196
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20197 {
20198 72 beam_power[x]=get_qr(qr_HIDECARRIEDITEMS)?50:100;
20199 72 }
20200
20201 18 set_qr(qr_HIDECARRIEDITEMS,0);
20202 18 hookshot_links=100;
20203 18 temp_zinit.msg_more_x=224;
20204 18 temp_zinit.msg_more_y=64;
20205 18 }
20206
20207 // Okay, let's put these legacy values into itemsbuf.
20208
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 82 times.
289 if(s_version < 15)
20209
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
20210 {
20211
11/11
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 20172 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 82 times.
20992 switch(i)
20212 {
20213 case iFairyStill:
20214 82 itemsbuf[i].misc1 = stationary_fairy_hearts;
20215 82 itemsbuf[i].misc2 = stationary_fairy_magic;
20216 82 itemsbuf[i].misc3 = 0;
20217
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
20218
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
20219 82 break;
20220
20221 case iFairyMoving:
20222 82 itemsbuf[i].misc1 = moving_fairy_hearts;
20223 82 itemsbuf[i].misc2 = moving_fairy_magic;
20224 82 itemsbuf[i].misc3 = 50;
20225
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
20226
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
20227 82 break;
20228
20229 case iRPotion:
20230 82 itemsbuf[i].misc1 = red_potion_hearts;
20231 82 itemsbuf[i].misc2 = red_potion_magic;
20232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
20233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
20234 82 break;
20235
20236 case iBPotion:
20237 82 itemsbuf[i].misc1 = blue_potion_hearts;
20238 82 itemsbuf[i].misc2 = blue_potion_magic;
20239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
20240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
20241 82 break;
20242
20243 case iSword:
20244 82 itemsbuf[i].pickup_hearts = sword_hearts[0];
20245 82 itemsbuf[i].misc1 = beam_hearts[0];
20246 82 itemsbuf[i].misc2 = beam_power[0];
20247 // It seems that item_flag1 was already added by reset_itembuf()...
20248 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~item_flag1 : ~item_none;
20249 82 break;
20250
20251 case iWSword:
20252 82 itemsbuf[i].pickup_hearts = sword_hearts[1];
20253 82 itemsbuf[i].misc1 = beam_hearts[1];
20254 82 itemsbuf[i].misc2 = beam_power[1];
20255 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~item_flag1 : ~item_none;
20256 82 break;
20257
20258 case iMSword:
20259 82 itemsbuf[i].pickup_hearts = sword_hearts[2];
20260 82 itemsbuf[i].misc1 = beam_hearts[2];
20261 82 itemsbuf[i].misc2 = beam_power[2];
20262 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~item_flag1 : ~item_none;
20263 82 break;
20264
20265 case iXSword:
20266 82 itemsbuf[i].pickup_hearts = sword_hearts[3];
20267 82 itemsbuf[i].misc1 = beam_hearts[3];
20268 82 itemsbuf[i].misc2 = beam_power[3];
20269 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~item_flag1 : ~item_none;
20270 82 break;
20271
20272 case iHookshot:
20273 82 itemsbuf[i].misc1 = hookshot_length;
20274 82 itemsbuf[i].misc2 = hookshot_links;
20275 82 break;
20276
20277 case iLongshot:
20278 82 itemsbuf[i].misc1 = longshot_length;
20279 82 itemsbuf[i].misc2 = longshot_links;
20280 82 break;
20281 }
20282 21074 }
20283
20284
6/6
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 266 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
289 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20285 {
20286 //was new subscreen rule
20287 22 subscr_mode=get_qr(qr_FREEFORM)?1:0;
20288 22 set_qr(qr_FREEFORM,0);
20289 22 }
20290
20291
5/6
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 266 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
289 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20292 {
20293 23 temp_zinit.start_dmap=0;
20294 23 }
20295
20296
5/6
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 266 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
289 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20297 {
20298 23 temp_zinit.heroAnimationStyle=get_qr(qr_BSZELDA)?1:0;
20299 23 }
20300
20301
3/4
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 207 times.
✓ Branch 2 taken 82 times.
✗ Branch 3 not taken.
289 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20302 {
20303 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20304 temp_zinit.mcounter[crMONEY]=999;
20305 //temp_zinit.counter[crMONEY]=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20306 }
20307
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 6 times.
289 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20308 {
20309 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20310 6 temp_zinit.mcounter[crBOMBS] = 8;
20311 6 }
20312 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20313 //time to ensure that we port all new values properly:
20314
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 82 times.
289 if(Header->zelda_version < 0x250)
20315 {
20316
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 temp_zinit.mcounter[crSBOMBS] = bomb_ratio > 0 ? ( temp_zinit.mcounter[crBOMBS]/temp_zinit.bomb_ratio ) : (temp_zinit.mcounter[crBOMBS]/4);
20317 82 }
20318
20319
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 271 times.
289 if(s_version > 21)
20320 {
20321
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.hp_per_heart,f))
20322 {
20323 return qe_invalid;
20324 }
20325
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.magic_per_block,f))
20326 {
20327 return qe_invalid;
20328 }
20329
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20330 {
20331 return qe_invalid;
20332 }
20333
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20334 {
20335 return qe_invalid;
20336 }
20337 18 }
20338 else
20339 {
20340 271 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20341 271 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20342 271 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20343 271 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20344 }
20345
20346
2/2
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 18 times.
289 if(s_version > 22)
20347 {
20348
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 18 times.
468 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 450 times.
450 if(!p_igetw(&temp_zinit.counter[q],f))
20350 return qe_invalid;
20351
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 18 times.
468 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 450 times.
450 if(!p_igetw(&temp_zinit.mcounter[q],f))
20353 return qe_invalid;
20354 18 }
20355
20356
20357
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 271 times.
289 if(s_version > 23)
20358 {
20359
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.dither_type,f))
20360 {
20361 return qe_invalid;
20362 }
20363
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.dither_arg,f))
20364 {
20365 return qe_invalid;
20366 }
20367
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.dither_percent,f))
20368 {
20369 return qe_invalid;
20370 }
20371
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.def_lightrad,f))
20372 {
20373 return qe_invalid;
20374 }
20375
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.transdark_percent,f))
20376 {
20377 return qe_invalid;
20378 }
20379 18 }
20380 else
20381 {
20382 271 temp_zinit.dither_type = 0;
20383 271 temp_zinit.dither_arg = 0;
20384 271 temp_zinit.dither_percent = 20;
20385 271 temp_zinit.def_lightrad = 24;
20386 271 temp_zinit.transdark_percent = 0;
20387 }
20388
20389
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 271 times.
289 if(s_version > 24)
20390 {
20391
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.darkcol,f))
20392 {
20393 return qe_invalid;
20394 }
20395 18 }
20396 else
20397 {
20398 271 temp_zinit.darkcol = BLACK;
20399 }
20400
20401
2/2
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 18 times.
289 if(s_version > 25)
20402 {
20403
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetl(&temp_zinit.gravity,f))
20404 {
20405 return qe_invalid;
20406 }
20407
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetl(&temp_zinit.swimgravity,f))
20408 {
20409 return qe_invalid;
20410 }
20411 18 }
20412
20413
20414
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 271 times.
289 if(s_version > 26)
20415 {
20416
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20417 {
20418 return qe_invalid;
20419 }
20420
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20421 {
20422 return qe_invalid;
20423 }
20424
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20425 {
20426 return qe_invalid;
20427 }
20428 18 }
20429 else
20430 {
20431 271 temp_zinit.heroSideswimUpStep = 150;
20432 271 temp_zinit.heroSideswimSideStep = 100;
20433 271 temp_zinit.heroSideswimDownStep = 75;
20434 }
20435
20436
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 271 times.
289 if(s_version > 27)
20437 {
20438
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20439 {
20440 return qe_invalid;
20441 }
20442 18 }
20443 else
20444 {
20445 271 temp_zinit.exitWaterJump = 0;
20446 }
20447
20448
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 271 times.
289 if(s_version > 29)
20449 {
20450
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20451 {
20452 return qe_invalid;
20453 }
20454 18 }
20455 else
20456 {
20457 271 temp_zinit.bunny_ltm = 0;
20458 }
20459
20460
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 271 times.
289 if(s_version > 30)
20461 {
20462
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.switchhookstyle,f))
20463 {
20464 return qe_invalid;
20465 }
20466 18 }
20467 else
20468 {
20469 271 temp_zinit.switchhookstyle = 1;
20470 }
20471
20472
2/2
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 18 times.
289 if(s_version > 31)
20473 {
20474
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.magicdrainrate,f))
20475 {
20476 return qe_invalid;
20477 }
20478 18 }
20479
20480 289 temp_zinit.clear_genscript();
20481
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 13 times.
289 if(s_version > 32)
20482 {
20483 13 word numgenscript = 0;
20484
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&numgenscript,f))
20485 return qe_invalid;
20486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (numgenscript > NUMSCRIPTSGENERIC)
20487 return qe_invalid;
20488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 for(auto q = 1; q < numgenscript; ++q)
20489 {
20490 if(!p_getc(&tempbyte,f))
20491 return qe_invalid;
20492 if(!(tempbyte&2))
20493 continue;
20494 temp_zinit.gen_doscript.set(q, tempbyte&1);
20495 if(!p_igetw(&temp_zinit.gen_exitState[q],f))
20496 return qe_invalid;
20497 if(!p_igetw(&temp_zinit.gen_reloadState[q],f))
20498 return qe_invalid;
20499 for(auto p = 0; p < 8; ++p)
20500 if(!p_igetl(&temp_zinit.gen_initd[q][p],f))
20501 return qe_invalid;
20502 dword sz;
20503 if(!p_igetl(&sz,f))
20504 return qe_invalid;
20505 temp_zinit.gen_data[q].resize(sz);
20506 std::vector<int32_t> dummy;
20507 if(!p_getlvec(&dummy,f))
20508 return qe_invalid;
20509 temp_zinit.gen_data[q] = dummy;
20510 if(!p_igetl(&temp_zinit.gen_eventstate[q],f))
20511 return qe_invalid;
20512 }
20513 13 }
20514
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 7 times.
289 if(s_version > 33)
20515 {
20516
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20517 return qe_invalid;
20518
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_zinit.hero_swim_div,f))
20519 return qe_invalid;
20520 7 }
20521
1/2
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
289 if(s_version > 34)
20522 {
20523 uint32_t num_used_mapscr_data;
20524 if(!p_igetl(&num_used_mapscr_data,f))
20525 return qe_invalid;
20526 for(uint32_t q = 0; q < num_used_mapscr_data; ++q)
20527 {
20528 uint32_t sz;
20529 if(!p_igetl(&sz,f))
20530 return qe_invalid;
20531 temp_zinit.screen_data[q].resize(sz);
20532 if(sz)
20533 {
20534 std::vector<int32_t> dummy;
20535 if(!p_getlvec(&dummy,f))
20536 return qe_invalid;
20537 temp_zinit.screen_data[q] = dummy;
20538 }
20539 }
20540 }
20541
1/2
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
289 if (s_version > 35)
20542 if(!p_igetzf(&temp_zinit.shove_offset,f))
20543 return qe_invalid;
20544
20545 289 temp_zinit.counter[crLIFE] *= temp_zinit.hp_per_heart;
20546 289 temp_zinit.mcounter[crLIFE] *= temp_zinit.hp_per_heart;
20547
2/2
✓ Branch 0 taken 188 times.
✓ Branch 1 taken 101 times.
289 if(!temp_zinit.flags.get(INIT_FL_CONTPERCENT))
20548 101 temp_zinit.cont_heart *= temp_zinit.hp_per_heart;
20549
20550 289 return 0;
20551 289 }
20552 692 int32_t readinitdata(PACKFILE *f, zquestheader *Header)
20553 {
20554 692 zinitdata temp_zinit = {};
20555
20556
3/4
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
692 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
20557
20558 int32_t dummy;
20559 692 word s_version=0, s_cversion=0;
20560 byte padding;
20561
20562
2/2
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 23 times.
692 if(Header->zelda_version > 0x192)
20563 {
20564
2/4
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 669 times.
✗ Branch 3 not taken.
669 if(!p_igetw(&s_version,f))
20565 return qe_invalid;
20566 669 FFCore.quest_format[vInitData] = s_version;
20567
20568
2/4
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 669 times.
✗ Branch 3 not taken.
669 if(!p_igetw(&s_cversion,f))
20569 return qe_invalid;
20570
20571 //section size
20572
2/4
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 669 times.
✗ Branch 3 not taken.
669 if(!p_igetl(&dummy,f))
20573 return qe_invalid;
20574 669 }
20575
20576
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 403 times.
692 if(s_version < 37)
20577 {
20578
2/4
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 289 times.
289 if(auto ret = readinitdata_old(f,Header,s_version,s_cversion,temp_zinit))
20579 return ret;
20580 289 }
20581 else
20582 {
20583 403 subscr_mode = ssdtMAX;
20584
2/2
✓ Branch 0 taken 12896 times.
✓ Branch 1 taken 403 times.
13299 for(int q = 0; q < MAXITEMS/8; ++q)
20585
2/4
✓ Branch 0 taken 12896 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12896 times.
12896 if(!p_getc(&temp_zinit.items[q], f))
20586 return qe_invalid;
20587
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 25792 times.
26195 for(int q = 0; q < MAXLEVELS/8; ++q)
20588 {
20589
2/4
✓ Branch 0 taken 25792 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25792 times.
✗ Branch 3 not taken.
25792 if(!p_getc(&temp_zinit.map[q], f))
20590 return qe_invalid;
20591
2/4
✓ Branch 0 taken 25792 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25792 times.
25792 if(!p_getc(&temp_zinit.compass[q], f))
20592 return qe_invalid;
20593
2/4
✓ Branch 0 taken 25792 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25792 times.
25792 if(!p_getc(&temp_zinit.boss_key[q], f))
20594 return qe_invalid;
20595
2/4
✓ Branch 0 taken 25792 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25792 times.
✗ Branch 3 not taken.
25792 if(!p_getc(&temp_zinit.mcguffin[q], f))
20596 return qe_invalid;
20597 25792 }
20598
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getbvec(&temp_zinit.level_keys, f))
20599 return qe_invalid;
20600 byte num_counters;
20601
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&num_counters,f))
20602 return qe_invalid;
20603
2/2
✓ Branch 0 taken 43121 times.
✓ Branch 1 taken 403 times.
43524 for(int q = 0; q < num_counters; ++q)
20604
2/4
✓ Branch 0 taken 43121 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 43121 times.
43121 if(!p_igetw(&temp_zinit.counter[q],f))
20605 return qe_invalid;
20606
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 43121 times.
43524 for(int q = 0; q < num_counters; ++q)
20607
2/4
✓ Branch 0 taken 43121 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 43121 times.
43121 if(!p_igetw(&temp_zinit.mcounter[q],f))
20608 return qe_invalid;
20609
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&temp_zinit.bomb_ratio,f))
20610 return qe_invalid;
20611
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&temp_zinit.hcp,f))
20612 return qe_invalid;
20613
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&temp_zinit.hcp_per_hc,f))
20614 return qe_invalid;
20615
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetw(&temp_zinit.cont_heart,f))
20616 return qe_invalid;
20617
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&temp_zinit.hp_per_heart,f))
20618 return qe_invalid;
20619
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&temp_zinit.magic_per_block,f))
20620 return qe_invalid;
20621
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20622 return qe_invalid;
20623
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20624 return qe_invalid;
20625
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&temp_zinit.dither_type,f))
20626 return qe_invalid;
20627
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&temp_zinit.dither_arg,f))
20628 return qe_invalid;
20629
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&temp_zinit.dither_percent,f))
20630 return qe_invalid;
20631
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&temp_zinit.def_lightrad,f))
20632 return qe_invalid;
20633
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&temp_zinit.transdark_percent,f))
20634 return qe_invalid;
20635
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&temp_zinit.darkcol,f))
20636 return qe_invalid;
20637
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetl(&temp_zinit.ss_grid_x,f))
20638 return qe_invalid;
20639
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetl(&temp_zinit.ss_grid_y,f))
20640 return qe_invalid;
20641
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetl(&temp_zinit.ss_grid_xofs,f))
20642 return qe_invalid;
20643
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetl(&temp_zinit.ss_grid_yofs,f))
20644 return qe_invalid;
20645
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetl(&temp_zinit.ss_grid_color,f))
20646 return qe_invalid;
20647
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetl(&temp_zinit.ss_bbox_1_color,f))
20648 return qe_invalid;
20649
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetl(&temp_zinit.ss_bbox_2_color,f))
20650 return qe_invalid;
20651
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetl(&temp_zinit.ss_flags,f))
20652 return qe_invalid;
20653
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getbitstr(&temp_zinit.flags,f))
20654 return qe_invalid;
20655
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&temp_zinit.last_map,f))
20656 return qe_invalid;
20657
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&temp_zinit.last_screen,f))
20658 return qe_invalid;
20659
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&temp_zinit.msg_more_x,f))
20660 return qe_invalid;
20661
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&temp_zinit.msg_more_y,f))
20662 return qe_invalid;
20663
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20664 return qe_invalid;
20665
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&temp_zinit.msg_speed,f))
20666 return qe_invalid;
20667
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetl(&temp_zinit.gravity,f))
20668 return qe_invalid;
20669
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetl(&temp_zinit.swimgravity,f))
20670 return qe_invalid;
20671
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetw(&temp_zinit.terminalv,f))
20672 return qe_invalid;
20673
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&temp_zinit.hero_swim_speed,f))
20674 return qe_invalid;
20675
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20676 return qe_invalid;
20677
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&temp_zinit.hero_swim_div,f))
20678 return qe_invalid;
20679
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20680 return qe_invalid;
20681
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20682 return qe_invalid;
20683
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20684 return qe_invalid;
20685
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20686 return qe_invalid;
20687
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetw(&temp_zinit.heroStep,f))
20688 return qe_invalid;
20689
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20690 return qe_invalid;
20691
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20692 return qe_invalid;
20693
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20694 return qe_invalid;
20695
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetw(&temp_zinit.start_dmap,f))
20696 return qe_invalid;
20697
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20698 return qe_invalid;
20699
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&temp_zinit.switchhookstyle,f))
20700 return qe_invalid;
20701
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&temp_zinit.magicdrainrate,f))
20702 return qe_invalid;
20703
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetzf(&temp_zinit.shove_offset,f))
20704 return qe_invalid;
20705
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getbitstr(&temp_zinit.gen_doscript, f))
20706 return qe_invalid;
20707
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getbmap(&temp_zinit.gen_exitState, f))
20708 return qe_invalid;
20709
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getbmap(&temp_zinit.gen_reloadState, f))
20710 return qe_invalid;
20711
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getbmap(&temp_zinit.gen_initd, f))
20712 return qe_invalid;
20713
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getbmap(&temp_zinit.gen_eventstate, f))
20714 return qe_invalid;
20715
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getbmap(&temp_zinit.gen_data, f))
20716 return qe_invalid;
20717
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getbmap(&temp_zinit.screen_data, f))
20718 return qe_invalid;
20719
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if (s_version >= 38)
20720 {
20721
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if (!p_getc(&temp_zinit.spriteflickerspeed, f))
20722 return qe_invalid;
20723
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if (!p_getc(&temp_zinit.spriteflickercolor, f))
20724 return qe_invalid;
20725
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if (!p_getc(&temp_zinit.spriteflickertransp, f))
20726 return qe_invalid;
20727 403 }
20728
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 299 times.
403 if(s_version >= 39)
20729
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_igetzf(&temp_zinit.air_drag, f))
20730 return qe_invalid;
20731 }
20732
1/2
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
692 if (should_skip)
20733 return 0;
20734
20735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
692 if(loading_tileset_flags & TILESET_CLEARMAPS)
20736 {
20737 temp_zinit.last_map = 0;
20738 temp_zinit.last_screen = 0;
20739 temp_zinit.screen_data.clear();
20740 }
20741
1/2
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
692 temp_zinit.normalize();
20742
1/2
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
692 zinit = temp_zinit;
20743
20744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
692 if(zinit.heroAnimationStyle==las_zelda3slow)
20745 {
20746 hero_animation_speed=2;
20747 }
20748 else
20749 {
20750 692 hero_animation_speed=1;
20751 }
20752
20753 692 return 0;
20754 692 }
20755
20756 /*
20757 void setupitemdropsets()
20758 {
20759 for(int32_t i=0; i<isMAX; i++)
20760 {
20761 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
20762 }
20763 }
20764 */
20765
20766 633 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build)
20767 {
20768
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 23 times.
633 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_itemdropsets);
20769
20770 633 build=build; // here to prevent compiler warnings
20771 dword dummy_dword;
20772 633 word item_drop_sets_to_read=0;
20773 item_drop_object tempitemdrop;
20774 633 word s_version=0, s_cversion=0;
20775
20776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 633 times.
633 if (!should_skip)
20777
2/2
✓ Branch 0 taken 162048 times.
✓ Branch 1 taken 633 times.
162681 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
20778 {
20779 162048 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
20780 162681 }
20781
20782
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 23 times.
633 if(version > 0x192)
20783 {
20784 610 item_drop_sets_to_read=0;
20785
20786 //section version info
20787
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_igetw(&s_version,f))
20788 {
20789 return qe_invalid;
20790 }
20791
20792 610 FFCore.quest_format[vItemDropsets] = s_version;
20793
20794
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_igetw(&s_cversion,f))
20795 {
20796 return qe_invalid;
20797 }
20798
20799 //section size
20800
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_igetl(&dummy_dword,f))
20801 {
20802 return qe_invalid;
20803 }
20804
20805 //finally... section data
20806
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_igetw(&item_drop_sets_to_read,f))
20807 {
20808 return qe_invalid;
20809 }
20810
20811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if (item_drop_sets_to_read > MAXITEMDROPSETS)
20812 {
20813 return qe_invalid;
20814 }
20815 610 }
20816 else
20817 {
20818 23 init_item_drop_sets();
20819 }
20820
20821
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 610 times.
633 if(s_version>=1)
20822 {
20823
2/2
✓ Branch 0 taken 8765 times.
✓ Branch 1 taken 610 times.
9375 for(int32_t i=0; i<item_drop_sets_to_read; i++)
20824 {
20825
1/2
✓ Branch 0 taken 8765 times.
✗ Branch 1 not taken.
8765 if(!p_getstr(tempitemdrop.name,sizeof(tempitemdrop.name)-1,f))
20826 {
20827 return qe_invalid;
20828 }
20829
20830
2/2
✓ Branch 0 taken 87650 times.
✓ Branch 1 taken 8765 times.
96415 for(int32_t j=0; j<10; ++j)
20831 {
20832
1/2
✓ Branch 0 taken 87650 times.
✗ Branch 1 not taken.
87650 if(!p_igetw(&tempitemdrop.item[j],f))
20833 {
20834 return qe_invalid;
20835 }
20836 87650 }
20837
20838
2/2
✓ Branch 0 taken 96415 times.
✓ Branch 1 taken 8765 times.
105180 for(int32_t j=0; j<11; ++j)
20839 {
20840
1/2
✓ Branch 0 taken 96415 times.
✗ Branch 1 not taken.
96415 if(!p_igetw(&tempitemdrop.chance[j],f))
20841 {
20842 return qe_invalid;
20843 }
20844 96415 }
20845
20846 // Dec 2008: Addition of the 'Tall Grass' set, #12,
20847 // overrides the quest's set #12.
20848
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8765 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8765 if(s_version<2 && i==12)
20849 continue;
20850
20851 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
20852
1/4
✓ Branch 0 taken 8765 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8765 if(s_version<2) for(int32_t j=0; j<10; ++j)
20853 {
20854 int32_t it = tempitemdrop.item[j];
20855
20856 if((itemsbuf[it].family == itype_rupee
20857 && ((itemsbuf[it].amount)&0xFFF) == 10)
20858 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
20859 {
20860 tempitemdrop.chance[j+1]=0;
20861 }
20862 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
20863 {
20864 tempitemdrop.chance[j+1]=0;
20865 }
20866
20867 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
20868 if(itemsbuf[it].family == itype_misc)
20869 {
20870 // If a non-gameplay item was selected, then item drop was aborted.
20871 // Reflect this by increasing the 'Nothing' chance accordingly.
20872 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
20873 tempitemdrop.chance[j+1]=0;
20874 }
20875 }
20876
20877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8765 times.
8765 if (!should_skip)
20878 8765 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
20879 8765 }
20880 610 }
20881
20882 633 return 0;
20883 633 }
20884
20885 610 int32_t readfavorites(PACKFILE *f, int32_t, word)
20886 {
20887
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_favorites);
20888
20889 int32_t temp_num;
20890 dword dummy_dword;
20891 word num_favorite_combos;
20892 word num_favorite_combo_aliases;
20893 610 word s_version=0, s_cversion=0;
20894
20895 //section version info
20896
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_igetw(&s_version,f))
20897 {
20898 return qe_invalid;
20899 }
20900
20901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if (!should_skip)
20902 610 FFCore.quest_format[vFavourites] = s_version;
20903
20904
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_igetw(&s_cversion,f))
20905 {
20906 return qe_invalid;
20907 }
20908
20909 //section size
20910
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_igetl(&dummy_dword,f))
20911 {
20912 return qe_invalid;
20913 }
20914
20915 610 word per_row = FAVORITECOMBO_PER_ROW;
20916 610 word per_page = FAVORITECOMBO_PER_PAGE;
20917
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 410 times.
610 if(s_version >= 3)
20918
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_igetw(&per_row,f))
20919 return qe_invalid;
20920
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 403 times.
610 if(s_version >= 4)
20921
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 if(!p_igetw(&per_page,f))
20922 return qe_invalid;
20923 //finally... section data
20924
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(!p_igetw(&num_favorite_combos,f))
20925 {
20926 return qe_invalid;
20927 }
20928
20929 //Hack; port old favorite combos
20930
3/4
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 410 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 200 times.
610 if(s_version < 3 && num_favorite_combos == 100)
20931 200 per_row = 13;
20932
20933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if (!should_skip)
20934
2/2
✓ Branch 0 taken 768600 times.
✓ Branch 1 taken 610 times.
769210 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
20935 769210 favorite_combos[q] = -1;
20936 610 byte favtype = 0;
20937
2/2
✓ Branch 0 taken 63472 times.
✓ Branch 1 taken 610 times.
64082 for(int32_t i=0; i<num_favorite_combos; i++)
20938 {
20939
2/2
✓ Branch 0 taken 43465 times.
✓ Branch 1 taken 20007 times.
63472 if (s_version >= 4)
20940 {
20941
1/2
✓ Branch 0 taken 43465 times.
✗ Branch 1 not taken.
43465 if (!p_getc(&favtype, f))
20942 {
20943 return qe_invalid;
20944 }
20945 43465 }
20946 else
20947 20007 favtype = 0;
20948
1/2
✓ Branch 0 taken 63472 times.
✗ Branch 1 not taken.
63472 if(!p_igetl(&temp_num,f))
20949 {
20950 return qe_invalid;
20951 }
20952
20953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63472 times.
63472 if (should_skip)
20954 continue;
20955
20956
2/2
✓ Branch 0 taken 43465 times.
✓ Branch 1 taken 20007 times.
63472 if(per_row == FAVORITECOMBO_PER_ROW)
20957 {
20958 43465 favorite_combos[i] = temp_num;
20959 43465 favorite_combo_modes[i] = favtype;
20960 43465 }
20961 else
20962 {
20963 20007 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
20964 20007 favorite_combos[new_i]=temp_num;
20965 20007 favorite_combo_modes[new_i] = favtype;
20966 }
20967 63472 }
20968
20969 // Discard the separate favorite aliases list from previous versions
20970
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 207 times.
610 if(s_version<4)
20971 {
20972
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if (!p_igetw(&num_favorite_combo_aliases, f))
20973 {
20974 return qe_invalid;
20975 }
20976
20977
2/2
✓ Branch 0 taken 20000 times.
✓ Branch 1 taken 207 times.
20207 for (int32_t i = 0; i < num_favorite_combo_aliases; i++)
20978 {
20979
1/2
✓ Branch 0 taken 20000 times.
✗ Branch 1 not taken.
20000 if (!p_igetl(&temp_num, f))
20980 {
20981 return qe_invalid;
20982 }
20983 20000 }
20984 207 }
20985
20986 610 word max_combo_cols = 0;
20987 610 word max_mappages = 0;
20988
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 410 times.
610 if(s_version >= 2)
20989 {
20990
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_igetw(&max_combo_cols,f))
20991 return qe_invalid;
20992 410 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
20993
2/2
✓ Branch 0 taken 1640 times.
✓ Branch 1 taken 410 times.
2050 for(int q = 0; q < max_combo_cols; ++q)
20994 {
20995
1/2
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
1640 if(!p_igetl(&tmp,f))
20996 return qe_invalid;
20997
1/2
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
1640 if(!p_igetl(&tmp2,f))
20998 return qe_invalid;
20999
1/2
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
1640 if(!p_igetl(&tmp3,f))
21000 return qe_invalid;
21001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1640 times.
1640 if(q < MAX_COMBO_COLS)
21002 {
21003 1640 First[q] = tmp;
21004 1640 combo_alistpos[q] = tmp2;
21005 1640 combo_pool_listpos[q] = tmp3;
21006 1640 }
21007 1640 }
21008
21009
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 if(!p_igetw(&max_mappages,f))
21010 return qe_invalid;
21011
2/2
✓ Branch 0 taken 3690 times.
✓ Branch 1 taken 410 times.
4100 for(int q = 0; q < max_mappages; ++q)
21012 {
21013
1/2
✓ Branch 0 taken 3690 times.
✗ Branch 1 not taken.
3690 if(!p_igetl(&tmp,f))
21014 return qe_invalid;
21015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3690 times.
3690 if(!p_igetl(&tmp2,f))
21016 return qe_invalid;
21017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3690 times.
3690 if(q < MAX_MAPPAGE_BTNS)
21018 {
21019 3690 map_page[q].map = tmp;
21020 3690 map_page[q].screen = tmp2;
21021 3690 }
21022 3690 }
21023 410 }
21024
21025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if (should_skip)
21026 return 0;
21027
21028
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 610 times.
1410 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21029 {
21030 800 First[q] = 0;
21031 800 combo_alistpos[q] = 0;
21032 800 combo_pool_listpos[q] = 0;
21033 800 }
21034
2/2
✓ Branch 0 taken 1800 times.
✓ Branch 1 taken 610 times.
2410 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21035 {
21036 1800 map_page[q].map = 0;
21037 1800 map_page[q].screen = 0;
21038 1800 }
21039
21040 610 return 0;
21041 610 }
21042
21043 /*
21044 switch (ret) {
21045 case 0:
21046 break;
21047
21048 case qe_invalid:
21049 goto invalid;
21050 break;
21051 default:
21052 pack_fclose(f);
21053 if(!oldquest)
21054 delete_file(tmpfilename);
21055 return ret;
21056 break;
21057 }
21058 */
21059
21060 const char *skip_text[skip_max]=
21061 {
21062 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21063 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21064 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21065 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21066 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21067 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21068 "skip_favorites"
21069 };
21070
21071
21072 void port250QuestRules(){
21073
21074 portCandleRules(); //Candle
21075 portBombRules();
21076
21077 }
21078
21079 void portCandleRules()
21080 {
21081 bool hurtshero = get_qr(qr_FIREPROOFHERO);
21082 //itemdata itemsbuf;
21083 for ( int32_t q = 0; q < MAXITEMS; q++ )
21084 {
21085 if ( itemsbuf[q].family == itype_candle )
21086 {
21087 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
21088 else itemsbuf[q].flags &= ~ item_flag2;
21089 }
21090 }
21091 }
21092
21093 void portBombRules()
21094 {
21095 bool hurtshero = get_qr(qr_OUCHBOMBS);
21096 //itemdata itemsbuf;
21097 for ( int32_t q = 0; q < MAXITEMS; q++ )
21098 {
21099 if ( itemsbuf[q].family == itype_bomb )
21100 {
21101 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
21102 else itemsbuf[q].flags &= ~ item_flag2;
21103 }
21104 }
21105 }
21106
21107 15933 static int section_id_to_enum(int id)
21108 {
21109
24/27
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 693 times.
✓ Branch 4 taken 693 times.
✓ Branch 5 taken 693 times.
✓ Branch 6 taken 610 times.
✓ Branch 7 taken 693 times.
✓ Branch 8 taken 693 times.
✓ Branch 9 taken 693 times.
✓ Branch 10 taken 693 times.
✓ Branch 11 taken 693 times.
✓ Branch 12 taken 693 times.
✓ Branch 13 taken 610 times.
✓ Branch 14 taken 610 times.
✓ Branch 15 taken 693 times.
✓ Branch 16 taken 693 times.
✓ Branch 17 taken 634 times.
✓ Branch 18 taken 610 times.
✓ Branch 19 taken 610 times.
✓ Branch 20 taken 610 times.
✓ Branch 21 taken 693 times.
✓ Branch 22 taken 693 times.
✓ Branch 23 taken 634 times.
✓ Branch 24 taken 610 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
15933 switch (id)
21110 {
21111 case ID_HEADER: return skip_header;
21112 693 case ID_RULES: return skip_rules;
21113 693 case ID_STRINGS: return skip_strings;
21114 693 case ID_MISC: return skip_misc;
21115 693 case ID_TILES: return skip_tiles;
21116 693 case ID_COMBOS: return skip_combos;
21117 610 case ID_COMBOALIASES: return skip_comboaliases;
21118 693 case ID_CSETS: return skip_csets;
21119 693 case ID_MAPS: return skip_maps;
21120 693 case ID_DMAPS: return skip_dmaps;
21121 693 case ID_DOORS: return skip_doors;
21122 693 case ID_ITEMS: return skip_items;
21123 693 case ID_WEAPONS: return skip_weapons;
21124 610 case ID_COLORS: return skip_colors;
21125 610 case ID_ICONS: return skip_icons;
21126 693 case ID_INITDATA: return skip_initdata;
21127 693 case ID_GUYS: return skip_guys;
21128 634 case ID_HEROSPRITES: return skip_herosprites;
21129 610 case ID_SUBSCREEN: return skip_subscreens;
21130 610 case ID_FFSCRIPT: return skip_ffscript;
21131 610 case ID_SFX: return skip_sfx;
21132 693 case ID_MIDIS: return skip_midis;
21133 693 case ID_CHEATS: return skip_cheats;
21134 634 case ID_ITEMDROPSETS: return skip_itemdropsets;
21135 610 case ID_FAVORITES: return skip_favorites;
21136 case ID_ZINFO: return skip_zinfo;
21137 }
21138
21139 return -1;
21140 15933 }
21141
21142 15525 static int maybe_skip_section(PACKFILE* f, dword& section_id, const byte* skip_flags)
21143 {
21144 15525 int section_enum = section_id_to_enum(section_id);
21145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15525 times.
15525 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
21146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15525 times.
15525 if (skip)
21147 {
21148 word s_version;
21149 if (!p_igetw(&s_version,f))
21150 {
21151 return qe_invalid;
21152 }
21153
21154 word c_version;
21155 if (!p_igetw(&c_version,f))
21156 {
21157 return qe_invalid;
21158 }
21159
21160 if (section_id == ID_RULES && s_version > 16)
21161 {
21162 dword dummy;
21163 if (!p_igetl(&dummy,f))
21164 {
21165 return qe_invalid;
21166 }
21167 }
21168
21169 if (section_id == ID_FFSCRIPT && s_version >= 18)
21170 {
21171 word dummy;
21172 if (!p_igetw(&dummy,f))
21173 {
21174 return qe_invalid;
21175 }
21176 }
21177
21178 dword section_length;
21179 if (!p_igetl(&section_length,f))
21180 {
21181 return qe_invalid;
21182 }
21183
21184 if (pack_fseek(f, section_length))
21185 {
21186 return qe_invalid;
21187 }
21188
21189 if (!pack_feof(f))
21190 {
21191 if (!p_mgetl(&section_id,f))
21192 {
21193 return qe_invalid;
21194 }
21195 }
21196
21197 return qe_cancel;
21198 }
21199
21200 15525 return qe_OK;
21201 15525 }
21202
21203 //Internal function for loadquest wrapper
21204 693 static int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata)
21205 {
21206 693 DMapEditorLastMaptileUsed = 0;
21207 693 combosread=false;
21208 693 mapsread=false;
21209 693 fixffcs=false;
21210
21211 693 bool do_clear_scripts = !get_bit(skip_flags,skip_ffscript);
21212
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
21213 {
21214 set_bit(skip_flags, skip_ffscript, 1);
21215 setZScriptVersion(V_FFSCRIPT);
21216 FFCore.quest_format[vFFScript] = V_FFSCRIPT;
21217 FFCore.quest_format[vLastCompile] = V_FFSCRIPT;
21218 do_clear_scripts = true;
21219 }
21220
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(loading_tileset_flags & TILESET_CLEARMAPS)
21221 {
21222 set_bit(skip_flags, skip_maps, 1);
21223 }
21224
21225 // show_progress=true;
21226 char tmpfilename[L_tmpnam];
21227 693 temp_name(tmpfilename);
21228 // char percent_done[30];
21229 693 bool catchup=false;
21230 byte tempbyte;
21231 693 word old_map_count=map_count;
21232
21233 693 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21234 693 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21235 693 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21236
21237
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 692 times.
693 if(get_bit(skip_flags, skip_rules))
21238 {
21239 1 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21240 1 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21241 1 }
21242
21243 693 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21244 693 unpack_qrs();
21245 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21246
21247
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 692 times.
693 if(get_bit(skip_flags, skip_midis))
21248 {
21249 1 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21250 1 }
21251
21252
21253
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 692 times.
693 if(do_clear_scripts)
21254 {
21255 692 zScript.clear();
21256 692 globalmap.clear();
21257 692 genericmap.clear();
21258 692 ffcmap.clear();
21259 692 itemmap.clear();
21260 692 npcmap.clear();
21261 692 ewpnmap.clear();
21262 692 lwpnmap.clear();
21263 692 playermap.clear();
21264 692 dmapmap.clear();
21265 692 screenmap.clear();
21266 692 itemspritemap.clear();
21267 692 comboscriptmap.clear();
21268 692 subscreenmap.clear();
21269
21270
2/2
✓ Branch 0 taken 353612 times.
✓ Branch 1 taken 692 times.
354304 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21271 {
21272 353612 ffcmap[i].clear();
21273 353612 }
21274
21275 692 globalmap[0].slotname = "Slot 1:";
21276 692 globalmap[0].scriptname = "~Init";
21277 692 globalmap[0].update();
21278
21279
2/2
✓ Branch 0 taken 4844 times.
✓ Branch 1 taken 692 times.
5536 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21280 {
21281 4844 globalmap[i].clear();
21282 4844 }
21283
21284
2/2
✓ Branch 0 taken 176460 times.
✓ Branch 1 taken 692 times.
177152 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21285 {
21286 176460 itemmap[i].clear();
21287 176460 }
21288
21289 //new script types -- prevent carrying over to a quest that you load after reading them
21290 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21291
2/2
✓ Branch 0 taken 176460 times.
✓ Branch 1 taken 692 times.
177152 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21292 {
21293 176460 npcmap[i].clear();
21294 176460 }
21295
2/2
✓ Branch 0 taken 176460 times.
✓ Branch 1 taken 692 times.
177152 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21296 {
21297 176460 lwpnmap[i].clear();
21298 176460 }
21299
2/2
✓ Branch 0 taken 176460 times.
✓ Branch 1 taken 692 times.
177152 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21300 {
21301 176460 ewpnmap[i].clear();
21302 176460 }
21303
2/2
✓ Branch 0 taken 2768 times.
✓ Branch 1 taken 692 times.
3460 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21304 {
21305 2768 playermap[i].clear();
21306 2768 }
21307
2/2
✓ Branch 0 taken 176460 times.
✓ Branch 1 taken 692 times.
177152 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21308 {
21309 176460 dmapmap[i].clear();
21310 176460 }
21311
2/2
✓ Branch 0 taken 176460 times.
✓ Branch 1 taken 692 times.
177152 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21312 {
21313 176460 screenmap[i].clear();
21314 176460 }
21315
2/2
✓ Branch 0 taken 176460 times.
✓ Branch 1 taken 692 times.
177152 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21316 {
21317 176460 itemspritemap[i].clear();
21318 176460 }
21319
2/2
✓ Branch 0 taken 353612 times.
✓ Branch 1 taken 692 times.
354304 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21320 {
21321 353612 comboscriptmap[i].clear();
21322 353612 }
21323
2/2
✓ Branch 0 taken 353612 times.
✓ Branch 1 taken 692 times.
354304 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21324 {
21325 353612 genericmap[i].clear();
21326 353612 }
21327
2/2
✓ Branch 0 taken 176460 times.
✓ Branch 1 taken 692 times.
177152 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN-1; i++)
21328 {
21329 176460 subscreenmap[i].clear();
21330 176460 }
21331
21332 692 reset_scripts();
21333 692 }
21334
21335 zquestheader tempheader;
21336 693 memset(&tempheader, 0, sizeof(zquestheader));
21337 693 zinfo tempzi;
21338 693 tempzi.clear();
21339 693 load_tmp_zi = &tempzi;
21340
21341 // oldquest flag is set when an unencrypted qst file is suspected.
21342 693 bool oldquest = false;
21343 693 int32_t open_error=0;
21344 693 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
21345
21346
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if (!f)
21347 {
21348 ASSERT(open_error != 0);
21349 return open_error;
21350 }
21351 char zinfofilename[2048];
21352 693 replace_extension(zinfofilename, filename, "zinfo", 2047);
21353 693 int32_t ret=0;
21354
21355 //header
21356 693 box_out("Reading Header...");
21357 693 ret=readheader(f, &tempheader, printmetadata);
21358
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
693 checkstatus(ret);
21359 693 box_out("okay.");
21360 693 box_eol();
21361
21362
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 421 times.
693 if(read_zinfo)
21363 {
21364 421 box_out("Reading ZInfo - ");
21365
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 418 times.
421 box_out(read_ext_zinfo ? "External..." : "Internal...");
21366
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 418 times.
421 if(read_ext_zinfo)
21367 {
21368 3 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21369 3 ret=readzinfo(inf, tempzi, tempheader);
21370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(inf) pack_fclose(inf);
21371
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
3 checkstatus(ret);
21372 3 }
21373 else
21374 {
21375 418 ret=readzinfo(f, tempzi, tempheader);
21376
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 418 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
418 checkstatus(ret);
21377 }
21378 421 box_out("okay.");
21379 421 box_eol();
21380 421 }
21381
21382
2/2
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 24 times.
693 if(tempheader.zelda_version>=0x193)
21383 {
21384 dword section_id;
21385
21386 //section id
21387
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 if(!p_mgetl(&section_id,f))
21388 {
21389 goto invalid;
21390 }
21391
21392 669 std::set<dword> seen_sections;
21393
21394
3/4
✓ Branch 0 taken 16194 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15525 times.
✓ Branch 3 taken 669 times.
16194 while(!pack_feof(f))
21395 {
21396
2/4
✓ Branch 0 taken 15525 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15525 times.
✗ Branch 3 not taken.
15525 if (seen_sections.contains(section_id))
21397 goto invalid;
21398
1/2
✓ Branch 0 taken 15525 times.
✗ Branch 1 not taken.
15525 seen_sections.insert(section_id);
21399
21400
2/4
✓ Branch 0 taken 15525 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15525 times.
✗ Branch 3 not taken.
15525 if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
21401 {
21402 if (retval == qe_cancel)
21403 continue;
21404 checkstatus(retval);
21405 }
21406
21407
24/25
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 669 times.
✓ Branch 2 taken 669 times.
✓ Branch 3 taken 669 times.
✓ Branch 4 taken 669 times.
✓ Branch 5 taken 610 times.
✓ Branch 6 taken 669 times.
✓ Branch 7 taken 669 times.
✓ Branch 8 taken 669 times.
✓ Branch 9 taken 669 times.
✓ Branch 10 taken 669 times.
✓ Branch 11 taken 669 times.
✓ Branch 12 taken 610 times.
✓ Branch 13 taken 610 times.
✓ Branch 14 taken 669 times.
✓ Branch 15 taken 669 times.
✓ Branch 16 taken 610 times.
✓ Branch 17 taken 610 times.
✓ Branch 18 taken 610 times.
✓ Branch 19 taken 610 times.
✓ Branch 20 taken 669 times.
✓ Branch 21 taken 669 times.
✓ Branch 22 taken 610 times.
✓ Branch 23 taken 610 times.
✗ Branch 24 not taken.
15525 switch(section_id)
21408 {
21409 case ID_RULES:
21410
21411 //rules
21412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
669 if(catchup)
21413 {
21414 box_out("found.");
21415 box_eol();
21416 catchup=false;
21417 }
21418
21419
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("Reading Rules...");
21420
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 ret=readrules(f, &tempheader);
21421
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 669 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
669 checkstatus(ret);
21422
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("okay.");
21423
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_eol();
21424 669 break;
21425
21426 case ID_STRINGS:
21427
21428 //strings
21429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
669 if(catchup)
21430 {
21431 box_out("found.");
21432 box_eol();
21433 catchup=false;
21434 }
21435
21436
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("Reading Strings...");
21437
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 ret=readstrings(f, &tempheader);
21438
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
669 checkstatus(ret);
21439
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("okay.");
21440
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_eol();
21441 669 break;
21442
21443 case ID_MISC:
21444
21445 //misc data
21446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
669 if(catchup)
21447 {
21448 box_out("found.");
21449 box_eol();
21450 catchup=false;
21451 }
21452
21453
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("Reading Misc. Data...");
21454
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 ret=readmisc(f, &tempheader, Misc);
21455
1/9
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
669 checkstatus(ret);
21456
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("okay.");
21457
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_eol();
21458 669 break;
21459
21460 case ID_TILES:
21461
21462 //tiles
21463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
669 if(catchup)
21464 {
21465 box_out("found.");
21466 box_eol();
21467 catchup=false;
21468 }
21469
21470
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("Reading Tiles...");
21471
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false);
21472
1/9
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
669 checkstatus(ret);
21473
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("okay.");
21474
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_eol();
21475 669 break;
21476
21477 case ID_COMBOS:
21478
21479 //combos
21480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
669 if(catchup)
21481 {
21482 box_out("found.");
21483 box_eol();
21484 catchup=false;
21485 }
21486
21487
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("Reading Combos...");
21488
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS);
21489 669 combosread=true;
21490
1/9
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
669 checkstatus(ret);
21491
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("okay.");
21492
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_eol();
21493 669 break;
21494
21495 case ID_COMBOALIASES:
21496
21497 //combo aliases
21498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if(catchup)
21499 {
21500 box_out("found.");
21501 box_eol();
21502 catchup=false;
21503 }
21504
21505
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_out("Reading Combo Aliases...");
21506
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build);
21507
1/9
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
610 checkstatus(ret);
21508
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_out("okay.");
21509
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_eol();
21510 610 break;
21511
21512 case ID_CSETS:
21513
21514 //color data
21515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
669 if(catchup)
21516 {
21517 box_out("found.");
21518 box_eol();
21519 catchup=false;
21520 }
21521
21522
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("Reading Color Data...");
21523
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL);
21524
1/9
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
669 checkstatus(ret);
21525
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("okay.");
21526
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_eol();
21527 669 break;
21528
21529 case ID_MAPS:
21530
21531 //maps
21532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
669 if(catchup)
21533 {
21534 box_out("found.");
21535 box_eol();
21536 catchup=false;
21537 }
21538
21539
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("Reading Maps...");
21540
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 ret=readmaps(f, &tempheader);
21541 669 mapsread=true;
21542
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
669 checkstatus(ret);
21543
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("okay.");
21544
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_eol();
21545 669 break;
21546
21547 case ID_DMAPS:
21548
21549 //dmaps
21550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
669 if(catchup)
21551 {
21552 box_out("found.");
21553 box_eol();
21554 catchup=false;
21555 }
21556
21557
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("Reading DMaps...");
21558
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS);
21559
1/9
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
669 checkstatus(ret);
21560
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("okay.");
21561
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_eol();
21562 669 break;
21563
21564 case ID_DOORS:
21565
21566 //door combo sets
21567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
669 if(catchup)
21568 {
21569 box_out("found.");
21570 box_eol();
21571 catchup=false;
21572 }
21573
21574
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("Reading Doors...");
21575
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 ret=readdoorcombosets(f, &tempheader);
21576
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
669 checkstatus(ret);
21577
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("okay.");
21578
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_eol();
21579 669 break;
21580
21581 case ID_ITEMS:
21582
21583 //items
21584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
669 if(catchup)
21585 {
21586 box_out("found.");
21587 box_eol();
21588 catchup=false;
21589 }
21590
21591
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("Reading Items...");
21592
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 ret=readitems(f, tempheader.zelda_version, tempheader.build);
21593
1/9
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
669 checkstatus(ret);
21594
21595
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("okay.");
21596
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_eol();
21597 669 break;
21598
21599 case ID_WEAPONS:
21600
21601 //weapons
21602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
669 if(catchup)
21603 {
21604 box_out("found.");
21605 box_eol();
21606 catchup=false;
21607 }
21608
21609
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("Reading Weapons...");
21610
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 ret=readweapons(f, &tempheader);
21611
1/9
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
669 checkstatus(ret);
21612
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("okay.");
21613
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_eol();
21614 669 break;
21615
21616 case ID_COLORS:
21617
21618 //misc. colors
21619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if(catchup)
21620 {
21621 box_out("found.");
21622 box_eol();
21623 catchup=false;
21624 }
21625
21626
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_out("Reading Misc. Colors...");
21627
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 ret=readmisccolors(f, &tempheader, Misc);
21628
1/9
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
610 checkstatus(ret);
21629
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_out("okay.");
21630
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_eol();
21631 610 break;
21632
21633 case ID_ICONS:
21634
21635 //game icons
21636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if(catchup)
21637 {
21638 box_out("found.");
21639 box_eol();
21640 catchup=false;
21641 }
21642
21643
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_out("Reading Game Icons...");
21644
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 ret=readgameicons(f, &tempheader, Misc);
21645
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
610 checkstatus(ret);
21646
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_out("okay.");
21647
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_eol();
21648 610 break;
21649
21650 case ID_INITDATA:
21651
21652 //initialization data
21653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
669 if(catchup)
21654 {
21655 box_out("found.");
21656 box_eol();
21657 catchup=false;
21658 }
21659
21660
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("Reading Init. Data...");
21661
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 ret=readinitdata(f, &tempheader);
21662
1/9
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
669 checkstatus(ret);
21663
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("okay.");
21664
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_eol();
21665
21666
2/4
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 669 times.
669 if(!get_bit(skip_flags, skip_subscreens))
21667 {
21668
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 585 times.
669 if(subscr_mode!=ssdtMAX) //not using custom subscreens
21669 {
21670
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 setupsubscreens();
21671
21672
2/2
✓ Branch 0 taken 43008 times.
✓ Branch 1 taken 84 times.
43092 for(int32_t i=0; i<MAXDMAPS; ++i)
21673 {
21674 43008 int32_t type=DMaps[i].type&dmfTYPE;
21675
2/2
✓ Branch 0 taken 1076 times.
✓ Branch 1 taken 41932 times.
43008 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21676 43008 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
21677 43008 }
21678 84 }
21679 669 }
21680
21681
2/4
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 669 times.
669 if(!get_bit(skip_flags, skip_sfx))
21682 {
21683 669 setupsfx();
21684 669 }
21685
21686
2/4
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 669 times.
✗ Branch 3 not taken.
669 if(!get_bit(skip_flags, skip_itemdropsets))
21687 {
21688
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 init_item_drop_sets();
21689 669 }
21690
21691
2/4
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 669 times.
669 if(!get_bit(skip_flags, skip_favorites))
21692 {
21693 669 init_favorites();
21694 669 }
21695
21696 669 break;
21697
21698 case ID_GUYS:
21699
21700 //guys
21701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
669 if(catchup)
21702 {
21703 box_out("found.");
21704 box_eol();
21705 catchup=false;
21706 }
21707
21708
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("Reading Custom Guy Data...");
21709
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 ret=readguys(f, &tempheader);
21710
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
669 checkstatus(ret);
21711
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("okay.");
21712
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_eol();
21713 669 break;
21714
21715 case ID_HEROSPRITES:
21716
21717 //player sprites
21718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if(catchup)
21719 {
21720 box_out("found.");
21721 box_eol();
21722 catchup=false;
21723 }
21724
21725
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_out("Reading Custom Player Sprite Data...");
21726
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 ret=readherosprites(f, &tempheader);
21727
1/9
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
610 checkstatus(ret);
21728
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_out("okay.");
21729
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_eol();
21730 610 break;
21731
21732 case ID_SUBSCREEN:
21733
21734 //custom subscreens
21735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if(catchup)
21736 {
21737 box_out("found.");
21738 box_eol();
21739 catchup=false;
21740 }
21741
21742
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_out("Reading Custom Subscreen Data...");
21743
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 ret=readsubscreens(f);
21744
1/9
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
610 checkstatus(ret);
21745
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_out("okay.");
21746
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_eol();
21747 610 break;
21748
21749 case ID_FFSCRIPT:
21750
21751 //Freeform combo scripts
21752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if(catchup)
21753 {
21754 box_out("found.");
21755 box_eol();
21756 catchup=false;
21757 }
21758
21759
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_out("Reading FF Script Data...");
21760
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 ret=readffscript(f, &tempheader);
21761
1/9
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
610 checkstatus(ret);
21762
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_out("okay.");
21763
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_eol();
21764 610 break;
21765
21766 case ID_SFX:
21767
21768 //SFX data
21769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if(catchup)
21770 {
21771 box_out("found.");
21772 box_eol();
21773 catchup=false;
21774 }
21775
21776
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_out("Reading SFX Data...");
21777
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 ret=readsfx(f, &tempheader);
21778
1/9
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
610 checkstatus(ret);
21779
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_out("okay.");
21780
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_eol();
21781 610 break;
21782
21783 case ID_MIDIS:
21784
21785 //midis
21786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
669 if(catchup)
21787 {
21788 box_out("found.");
21789 box_eol();
21790 catchup=false;
21791 }
21792
21793
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("Reading Tunes...");
21794
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 ret=readtunes(f, &tempheader, tunes);
21795
1/9
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
669 checkstatus(ret);
21796
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("okay.");
21797
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_eol();
21798 669 break;
21799
21800 case ID_CHEATS:
21801
21802 //cheat codes
21803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
669 if(catchup)
21804 {
21805 box_out("found.");
21806 box_eol();
21807 catchup=false;
21808 }
21809
21810
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("Reading Cheat Codes...");
21811
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 ret=readcheatcodes(f, &tempheader);
21812
1/9
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
669 checkstatus(ret);
21813
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_out("okay.");
21814
1/2
✓ Branch 0 taken 669 times.
✗ Branch 1 not taken.
669 box_eol();
21815 669 break;
21816
21817 case ID_ITEMDROPSETS:
21818
21819 //item drop sets
21820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if(catchup)
21821 {
21822 box_out("found.");
21823 box_eol();
21824 catchup=false;
21825 }
21826
21827
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_out("Reading Item Drop Sets...");
21828
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build);
21829
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
610 checkstatus(ret);
21830
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_out("okay.");
21831
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_eol();
21832 610 break;
21833
21834 case ID_FAVORITES:
21835
21836 //favorite combos and combo aliases
21837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if(catchup)
21838 {
21839 box_out("found.");
21840 box_eol();
21841 catchup=false;
21842 }
21843
21844
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_out("Reading Favorite Combos...");
21845
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 ret=readfavorites(f, tempheader.zelda_version, tempheader.build);
21846
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 610 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
610 checkstatus(ret);
21847
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_out("okay.");
21848
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 box_eol();
21849 610 break;
21850
21851 default:
21852 if(!catchup)
21853 {
21854 box_out("Bad token! Searching...");
21855 box_eol();
21856 }
21857
21858 catchup=true;
21859 break;
21860 }
21861
21862
21863
1/2
✓ Branch 0 taken 15525 times.
✗ Branch 1 not taken.
15525 if(catchup)
21864 {
21865 //section id
21866 section_id=(section_id<<8);
21867
21868 if(!p_getc(&tempbyte,f))
21869 {
21870 goto invalid;
21871 }
21872
21873 section_id+=tempbyte;
21874 }
21875
21876 else
21877 {
21878 //section id
21879
3/4
✓ Branch 0 taken 15525 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14856 times.
✓ Branch 3 taken 669 times.
15525 if(!pack_feof(f))
21880 {
21881
2/4
✓ Branch 0 taken 14856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14856 times.
✗ Branch 3 not taken.
14856 if(!p_mgetl(&section_id,f))
21882 {
21883 goto invalid;
21884 }
21885 14856 }
21886 }
21887 }
21888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
669 }
21889 else
21890 {
21891
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 std::vector<std::tuple<std::string, int32_t, std::function<int32_t()>>> hardcoded_sections = {
21892
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Rules", ID_RULES, [&](){ return readrules(f, &tempheader); }},
21893
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Strings", ID_STRINGS, [&](){ return readstrings(f, &tempheader); }},
21894
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Doors", ID_DOORS, [&](){ return readdoorcombosets(f, &tempheader); }},
21895
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "DMaps", ID_DMAPS, [&](){ return readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS); }},
21896
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Misc. Data", ID_MISC, [&](){ return readmisc(f, &tempheader, Misc); }},
21897
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Items", ID_ITEMS, [&](){ return readitems(f, tempheader.zelda_version, tempheader.build); }},
21898
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Weapons", ID_WEAPONS, [&](){ return readweapons(f, &tempheader); }},
21899
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Guy Data", ID_GUYS, [&](){ return readguys(f, &tempheader); }},
21900
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Maps", ID_MAPS, [&](){ return readmaps(f, &tempheader); }},
21901
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Combos", ID_COMBOS, [&](){ return readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS); }},
21902
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Color Data", ID_CSETS, [&](){ return readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL); }},
21903
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Tiles", ID_TILES, [&](){ return readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false); }},
21904
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Tunes", ID_MIDIS, [&](){ return readtunes(f, &tempheader, tunes); }},
21905
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Cheat Codes", ID_CHEATS, [&](){ return readcheatcodes(f, &tempheader); }},
21906
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Init. Data", ID_INITDATA, [&](){ return readinitdata(f, &tempheader); }},
21907
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Player Sprite Data", ID_HEROSPRITES, [&](){ return readherosprites2(f, -1, 0); }},
21908
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Up Default Item Drop Sets", ID_ITEMDROPSETS, [&](){ return readitemdropsets(f, -1, 0); }},
21909 };
21910
21911 24 legacy_skip_flags = skip_flags;
21912
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 408 times.
1250 for (auto& [desc, section_id, fn] : hardcoded_sections)
21913 {
21914
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 int section_enum = section_id_to_enum(section_id);
21915
2/4
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 408 times.
✗ Branch 3 not taken.
408 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
21916
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 16 times.
408 if (skip)
21917 {
21918 // Nothing to read.
21919
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 15 times.
16 if (section_id == ID_RULES)
21920 1 continue;
21921
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 14 times.
15 if (section_id == ID_GUYS)
21922 1 continue;
21923
21924 // Haven't looked at how to skip these, because we don't need to currently: the only
21925 // usage of skip_flags currently is all off except: header and tiles (see `load_imagebuf`).
21926
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (section_id == ID_MIDIS)
21927 1 continue;
21928
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 12 times.
13 if (section_id == ID_CHEATS)
21929 1 continue;
21930
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11 times.
12 if (section_id == ID_INITDATA)
21931 1 continue;
21932
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if (section_id == ID_HEROSPRITES)
21933 1 continue;
21934
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9 times.
10 if (section_id == ID_ITEMDROPSETS)
21935 1 continue;
21936 9 }
21937
21938 // Would be nice, but old sections mostly did not save section sizes. We could advance by
21939 // a specific amount, but it'd be a lot of work to get it right. So, for old quests, let's just
21940 // read all the sections even if requested to skip some.
21941 // if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
21942 // {
21943 // if (retval == qe_cancel)
21944 // continue;
21945 // checkstatus(retval);
21946 // }
21947
21948
3/6
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 401 times.
✗ Branch 5 not taken.
802 box_out(fmt::format("Reading {}...", desc).c_str());
21949
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 ret = fn();
21950
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
401 checkstatus(ret);
21951
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_out("okay.");
21952
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_eol();
21953 }
21954 24 legacy_skip_flags = nullptr;
21955
21956
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_subscreens))
21957 {
21958
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 setupsubscreens();
21959
21960
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 23 times.
11799 for(int32_t i=0; i<MAXDMAPS; ++i)
21961 {
21962 11776 int32_t type=DMaps[i].type&dmfTYPE;
21963
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11732 times.
11776 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21964 11776 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
21965 11776 }
21966 23 }
21967
21968
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("Setting Up Default Sound Effects...");
21969
21970
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 23 times.
24 if(!get_bit(skip_flags, skip_sfx))
21971 23 setupsfx();
21972
21973
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 23 times.
24 if(!get_bit(skip_flags, skip_favorites))
21974 23 init_favorites();
21975
21976
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("okay.");
21977
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_eol();
21978
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
24 }
21979
21980 693 init_spritelists();
21981
21982 // check data
21983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
693 if(f)
21984 {
21985 693 pack_fclose(f);
21986 693 }
21987 693 clear_quest_tmpfile();
21988
21989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
693 if(!oldquest)
21990 {
21991
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(exists(tmpfilename))
21992 {
21993 delete_file(tmpfilename);
21994 }
21995 693 }
21996
21997
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
693 if(fixffcs && combosread && mapsread)
21998 {
21999 for(int32_t i=0; i<map_count; i++)
22000 {
22001 for(int32_t j=0; j<MAPSCRS; j++)
22002 {
22003 for(int32_t m=0; m<32; m++)
22004 {
22005 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].data].type == cCHANGE)
22006 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffc_changer;
22007 }
22008 }
22009 }
22010 }
22011
22012
5/6
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 633 times.
✓ Branch 2 taken 59 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 59 times.
✗ Branch 5 not taken.
693 if(get_qr(qr_CONTFULL_DEP) && !get_bit(skip_flags, skip_rules) && !get_bit(skip_flags, skip_initdata))
22013 {
22014 59 set_qr(qr_CONTFULL_DEP, 0);
22015 59 zinit.flags.set(INIT_FL_CONTPERCENT,true);
22016 59 zinit.cont_heart=100;
22017 59 zinit.counter[crLIFE]=zinit.mcounter[crLIFE];
22018 59 }
22019
22020 693 box_out("Done.");
22021 693 box_eol();
22022 693 box_end(false);
22023
22024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
693 if(!get_bit(skip_flags, skip_header))
22025 {
22026 693 memcpy(Header, &tempheader, sizeof(tempheader));
22027 693 }
22028
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 692 times.
693 if(!get_bit(skip_flags, skip_zinfo))
22029 {
22030 692 ZI.copyFrom(tempzi);
22031 692 }
22032
22033
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 1 times.
693 if(get_bit(skip_flags, skip_maps))
22034 {
22035 1 map_count=old_map_count;
22036 1 }
22037
22038
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 1 times.
693 if(get_bit(skip_flags, skip_rules))
22039 {
22040 1 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22041 1 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22042 1 unpack_qrs();
22043 1 }
22044
22045
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 1 times.
693 if(get_bit(skip_flags, skip_midis))
22046 {
22047 1 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22048 1 }
22049
22050
2/2
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 24 times.
693 if( FFCore.quest_format[vZelda] < 0x210 )
22051 {
22052 24 zprint2("\n[QUEST METADATA]\n");
22053
22054
3/13
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
24 switch(FFCore.quest_format[vZelda])
22055 {
22056 case 0x193:
22057 {
22058 zprint2("Last saved in version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
22059 }
22060 case 0x192:
22061 {
22062 6 zprint2("Last saved in version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
22063 }
22064 case 0x190:
22065 {
22066 12 zprint2("Last saved in version: 1.90");
22067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22068 12 else zprint2("\n");
22069 12 break;
22070 }
22071 case 0x188:
22072 {
22073 zprint2("Last saved in version: 1.88");
22074 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22075 else zprint2("\n");
22076 break;
22077 }
22078 case 0x187:
22079 {
22080 zprint2("Last saved in version: 1.87");
22081 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22082 else zprint2("\n");
22083 break;
22084 }
22085 case 0x186:
22086 {
22087 zprint2("Last saved in version: 1.86");
22088 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22089 else zprint2("\n");
22090 break;
22091 }
22092 case 0x185:
22093 {
22094 zprint2("Last saved in version: 1.85");
22095 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22096 else zprint2("\n");
22097 break;
22098 }
22099 case 0x184:
22100 {
22101 6 zprint2("Last saved in version: 1.84");
22102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22103 6 else zprint2("\n");
22104 6 break;
22105 }
22106 case 0x183:
22107 {
22108 zprint2("Last saved in version: 1.83");
22109 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22110 else zprint2("\n");
22111 break;
22112 }
22113 case 0x182:
22114 {
22115 zprint2("Last saved in version: 1.82");
22116 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22117 else zprint2("\n");
22118 break;
22119 }
22120 case 0x181:
22121 {
22122 zprint2("Last saved in version: 1.81");
22123 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22124 else zprint2("\n");
22125 break;
22126 }
22127 case 0x180:
22128 {
22129 zprint2("Last saved in version: 1.80");
22130 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22131 else zprint2("\n");
22132 break;
22133 }
22134 default:
22135 {
22136 zprint2("Last saved in version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22137 }
22138 }
22139 24 }
22140
22141
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(loading_tileset_flags & TILESET_CLEARMAPS)
22142 {
22143 TheMaps.clear();
22144 TheMaps.resize(MAPSCRS*1);
22145 map_count = 1;
22146 map_autolayers.clear();
22147 map_autolayers.resize(6*1);
22148 for(size_t i = 0; i < MAPSCRS; ++i)
22149 {
22150 TheMaps[i].zero_memory();
22151 }
22152 }
22153
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(loading_tileset_flags & TILESET_CLEARHEADER)
22154 {
22155 memset(Header->password, 0, sizeof(Header->password));
22156 memset(Header->minver, 0, sizeof(Header->minver));
22157 memset(Header->title, 0, sizeof(Header->title));
22158 memset(Header->author, 0, sizeof(Header->author));
22159 memset(Header->version, 0, sizeof(Header->version));
22160 Header->use_keyfile = 0;
22161 Header->dirty_password = false;
22162 cvs_MD5Context ctx;
22163 cvs_MD5Init(&ctx);
22164 cvs_MD5Update(&ctx, (const uint8_t*)"", 0);
22165 cvs_MD5Final(Header->pwd_hash, &ctx);
22166 }
22167
22168 693 return qe_OK;
22169
22170 invalid:
22171 // TODO: It's too easy to forget to jump to this label, and accidentally leave the file open.
22172 // Should wrap PACKFILE in a std::unique_pointer with a custom deallocator.
22173 box_out("error.");
22174 box_eol();
22175 box_end(true);
22176
22177 pack_fclose(f);
22178
22179 if(!oldquest)
22180 {
22181 if(exists(tmpfilename))
22182 {
22183 delete_file(tmpfilename);
22184 }
22185 }
22186
22187 return qe_invalid;
22188
22189 693 }
22190
22191 static bool _is_loading_quest;
22192
22193 bool is_loading_quest()
22194 {
22195 return _is_loading_quest;
22196 }
22197
22198 693 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc,
22199 zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata,
22200 bool report, byte qst_num, dword tilesetflags)
22201 {
22202 693 loading_tileset_flags = tilesetflags;
22203 693 const char* basename = get_filename(filename);
22204 693 zapp_reporting_add_breadcrumb("load_quest", basename);
22205 693 zapp_reporting_set_tag("qst.filename", basename);
22206
22207 693 loading_qst_name = filename;
22208 693 loading_qst_num = qst_num;
22209 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22210 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22211
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if (!is_ci())
22212 loadquest_report = report;
22213
22214 693 _is_loading_quest = true;
22215 693 auto start = std::chrono::steady_clock::now();
22216 693 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, skip_flags, printmetadata);
22217 693 int32_t load_ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count();
22218 693 zprint2("Time to load qst: %d ms\n", load_ms);
22219 693 _is_loading_quest = false;
22220
22221
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 1 times.
693 if(show_progress)
22222 {
22223
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(ret)
22224 {
22225 box_out("-- Error loading quest file! --");
22226 box_end(true);
22227 }
22228 1 else box_end(false);
22229 1 }
22230
22231 693 load_tmp_zi = NULL;
22232 693 loading_qst_name = NULL;
22233 693 loadquest_report = false;
22234 693 loading_qst_num = 0;
22235
22236 693 zapp_reporting_set_tag("qst.author", Header->author);
22237 693 zapp_reporting_set_tag("qst.title", Header->title);
22238 693 zapp_reporting_set_tag("qst.zc_version", Header->getVerStr());
22239
22240 693 return ret;
22241 }
22242